Click here to return to the KiXtart HelpDesk main page...

KiXtart 2001 Manual

For ... Next

Action: Repeats a group of statements a specified number of times.
 
Syntax: FOR $counter = start TO end [STEP step] 
     statements… 
NEXT
  
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 Loop executes if 
Positive or 0 $counter <= end 
Negative $counter >= end


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.

Remarks: FOR NEXT loops can be nested as many times as memory allows.
Changing the value of counter while inside a loop can make it more difficult to read and debug your code.
 
See Also: Do Until, For Each, While Loop
 
Example:
For $Count = 0 To 10 Step 2
  ? $Count
Next