
The FOR...NEXT loop is a standard BASIC head-controlled loop. When the number of repetitions is known in advance, a FOR...NEXT loop should generally be preferred. FOR...NEXT increments a controlling variable by one, until the value given by TO is exceeded. If the optional keyword STEP exists, the value after STEP is added to the controlling variable instead of one. If this value is less than zero, the controlling variable is counted down.
The following program shows a simple FOR..NEXT loop that prints out the numbers from 0 to 10
outmode -2 for i=0 to 10 print i next
The next program shows the opposite, that is, counting down from 10 to 0
outmode -2 for i=10 to 0 step -1 print i next
In some situations when FOR...NEXT does not fit you needs, you can use DO...LOOP or WHILE...WEND constructs.