Part of the FOR statement, this optional section specifies step sizes other than 1.

FOR i=1 TO 20 STEP 5

The step may be positive or negative. STEP is optional; if it is omitted, a step size of +1 is assumed.

You can use this optional part of the FOR...TO...STEP...NEXT structure to specify the amount by which the FOR...NEXT loop control variable is changed each time round the loop. In the example below, the loop control variable, 'cost' starts as 20, ends at 5 and is changed by -5 each time round the loop.

10 FOR cost=20 TO 5 STEP -5
20   PRINT cost,cost*1.15


FOR <n-var>=<numeric> TO <numeric> [STEP <numeric>]

Associated Keywords