The DOLOOP command
allows statements
to be executed
a defined number of times with an incrementing variable.
The loop will always be executed at least once since
the loop-count variable will be incremented at the end of each loop.
This variable, if omitted, is an automatically created word named LOOP.
The variable may be used freely within the loop,
Example
DOLOOP LOOP1 FROM 1 TO 8 STEP 2 { ... NEWWORD = POSITION * LOOP1 INC NEWWORD POSSPEC ... }
will execute the commands within curly braces for values of the word LOOP1 of 1,3,5 and 7.
Example
The loop values may be negative ...
DOLOOP INDEX FROM 7 TO -2 STEP -3
will execute the contained commands for values of the variable INDEX of 7,4,1 and -2.
Example
To exit from a loop before the loop variable has reached the final loop value the IF...GOTO command should be used ...
DOLOOP FROM X1 TO X2 STEP I { ... IF ... GOTO ABCD ... } LABEL ABCD: ...