1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/*!
# `FOR <variable>=x TO y [STEP z]`
Where x, y, and z are expressions.
## Purpose
Used with `NEXT` to repeat execution of statements
while iterating over a sequence of numbers.
## Remarks
If we wanted the numbers 1,3,5,7 we would write `FOR I=1 TO 7 STEP 2`.
On the first iteration, 1 will be assigned to variable I.
Statements execute until a `NEXT` statement.
On subsequent iterations, the variable I gets 2 added to it.
If the result exceeds 7 the loop breaks.
Otherwise the statements get executed again.
The first iteration will evaluate x, then y, then z.
Newer versions of BASIC evaluate z first.
The first iteration always executes even if starting past the end.
Newer versions of BASIC may skip the first iteration.
## Example 1
```text
10 FOR I=1 TO 7 STEP 2
20 PRINT "HELLO WORLD";i
30 NEXT I
RUN
HELLO WORLD 1
HELLO WORLD 3
HELLO WORLD 5
HELLO WORLD 7
```
## Example 2
```text
10 FOR X=1 TO 2
20 FOR Y=5 TO 6
30 PRINT X;Y
40 NEXT Y,X
RUN
1 5
1 6
2 5
2 6
```
*/