Action |
Repeats a group of statements a specified number of times.
Syntax |
FOR $counter = start TO end [STEP step]
statements…
NEXT
FOR NEXT loops can be nested as many times as memory allows.
Parameters
Counter
Numeric variable used as a loop counter.
Start
Initial value of $counter.
End
Final value of $counter.
Step
Amount counter is changed each time through the loop. If not specified, step defaults to one. The step argument can be either positive or negative. The value of the step argument determines loop processing as follows:
Value
Positive or 0 $counter <= end
Negative $counter >= end
Remarks |
Once the loop starts and all statements in the loop have executed, Step is added to counter. At this point, either the statements in the loop execute again (based on the same test that caused the loop to execute initially), or the loop is exited and execution continues with the statement following the Next statement.
Changing the value of counter while inside a loop can make it more difficult to read and debug your code.
Example |
For $Count = 0 To 10 Step 2
?
$Count
Next