Overview | Statement List | Example 1 | Example 2 | Example 3
DO/label:,index variable,start,end[,increment]
The following provides an effective means of performing a given operation a specified number of times. The operation commonly referred to as a DO loop is a segment of the program which starts with the statement containing the word DO, followed by a slash and a label, and ends with the statement or blank statement which starts with the specified label.
Additional DO loops, referred to as nested loops, may exist inside of a loop, referencing either the same label or a separate label. If a separate label is used in a nested loop, both the DO statement and the specified label statement must exist within the outer loop.
Acceptable Jump Situations:
A jump may be made from a statement inside of a loop to a label which is also inside of the loop.
A jump may be made from a statement inside of a loop to a label which is outside of the loop (this terminates the loop).
Unacceptable Jump Situation:
A jump may not be made from a statement outside of a loop to a label which is inside of a loop.
NOTE: GRIP allows a total of 1000 labels per subroutine. The DO loop
generates two labels, the CALL command generates a label, and the
IFTHEN/ELSE/ELSEIF/ENDIF uses 2 labels plus 1 for every ELSEIF. These labels
count against the total you can use.
Parameter |
Description |
label: |
Specifies either the last executable statement in the loop or a blank statement following the last executable statement in the loop. |
index variable |
A variable which registers the current value of the loop. When the loop is entered the index variable is set to the start value, when the loop is finished the index variable is equal to the end value plus the increment value. |
start |
The starting value for the loop which may be either a constant, an expression or a variable. |
end |
The ending value for the loop which may be either a constant, an expression or a variable. |
increment |
The optional increment value for the loop which may be either a constant, an expression or a variable. If not specified the increment default is 1. |