FOR: Difference between revisions
From Macros Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{Command|syntax=FOR <variable> = <start> TO <end> [STEP <value>] | {{Command|syntax=FOR <loop variable> = <start> TO <end> [STEP <step value>] | ||
|description=*DESCRPTION* | |description=*DESCRPTION* | ||
|param1=<variable>|param1_desc={{number_variable}} | |param1=<loop variable>|param1_desc={{number_variable}} | ||
|param2=<start>|param2_desc= | |param2=<start>|param2_desc=Start value. The loop variable will initially be set to this start value | ||
|param3=TO|param3_desc= | |param3=TO|param3_desc=used to separate the start and end values | ||
|param4=<end>|param4_desc= | |param4=<end>|param4_desc=End value. The loop will be repeated until the loop variable reaches this end value. | ||
|param5=STEP|param5_desc= | |param5=STEP|param5_desc=used to indicate that a step value other than 1 is to be used. | ||
|param6=<value>|param6_desc= | |param6=<value>|param6_desc=Step. Each time the loop is executed, the loop variable will modified by adding this step value. | ||
}} | }} | ||
===Example=== | ===Example=== | ||
: | :FOR I = 1 TO 3 | ||
:FOR J = 2 TO 8 STEP 2 | |||
<br> | |||
:The first loop will execute 3 times, with I set to 1, 2 and 3.<b> | |||
:The second loop will execute 4 times with J set to 2, 4, 6 and 8. | |||
[[Category:Language]] | [[Category:Language]] | ||
Revision as of 21:21, 26 July 2010
Command
- FOR <loop variable> = <start> TO <end> [STEP <step value>]
- DESCRPTION*
Parameters
- <loop variable>
- A number variable.
- <start>
- Start value. The loop variable will initially be set to this start value
- TO
- used to separate the start and end values
- <end>
- End value. The loop will be repeated until the loop variable reaches this end value.
- STEP
- used to indicate that a step value other than 1 is to be used.
- <value>
- Step. Each time the loop is executed, the loop variable will modified by adding this step value.
Example
- FOR I = 1 TO 3
- FOR J = 2 TO 8 STEP 2
- The first loop will execute 3 times, with I set to 1, 2 and 3.
- The second loop will execute 4 times with J set to 2, 4, 6 and 8.