Begins a sequence of statements to be executed as a group, possibly to be executed iteratively.
DO [while-until-spec]|[index = iteration-spec[,iteration-spec]…]| FOREVER | LOOP;
where while-until-spec is:
WHILE(test-expression)[UNTIL(test-expression)]
or
UNTIL(test-expression)[WHILE(test-expression)]
and where
iteration-spec is:
start[to-by-spec|repeat-spec][while-until-spec]
where
to-by-spec is:
TO finish[BY increment]
or
BY increment[TO finish]
and where repeat-spec is:
REPEAT next
Description
The DO statement begins a sequence of statements to be executed in a group. The group ends with the nonexecutable statement END.
A DO-group is executed a variable number of times under the control of its DO statement.
A DO statement cannot be used as an ON-unit, but can appear anywhere within a procedure or BEGIN block, including a THEN or ELSE clause of an IF statement or as an object of a WHEN or OTHERWISE clause.
specifies an infinite loop. The GOTO or LEAVE statement, or terminating the program, is the only means of exiting the loop.
is the equivalent.
The following sections explain each DO statement. In all of these di