FOR Statement

Executes the provided statements while incrementing or decrementing a counter variable at each iteration.

The loop may be terminated without regard to the counter by using the BREAK statement. The current iteration of the loop can be abandoned and the next iteration of the loop started by using the CONTINUE statement.

Syntax


Parameters

Example

-- Prints the numbers: 1, 2, 3, 4, 5.
FOR @i = 1 TO 5
PRINT @i;

-- Prints the numbers: 5, 4, 3, 2, 1.
FOR @i = 5 TO 1
PRINT @i;

-- Prints the numbers: 1, 3, 5, 9.
FOR @i = 1 TO 10 STEP 2
PRINT @i;