FOR – TO – STEP – NEXT

The FOR-TO-STEP-NEXT control structure is a loop that counts from a numerical start value to a numerical end value in a defined increment. The step size is set to 1 by default and can optionally be changed with any number.

The syntax is

FOR variable = start value TO end value [STEP increment]
… instructions …
NEXT

The BREAK control command can be used to exit the loop immediately.

The CONTINUE control command starts the next iteration immediately.

Example

FOR I = 0 TO 10 STEP 1
PRINT I, I * I, I * I * I
NEXT