Execution proceeds as follows:
The specified expression is evaluated.
If the value of the expression is true, the statements in the range of the DO WHILE loop are executed.
If the value of the expression is false, control is transferred to the statement following the DO WHILE loop.
If s is specified, the statement identified by it is called the terminal statement, and it must follow the DO WHILE statement. The terminal statement must not be one of the following statements:
Unconditional GO TO
Assigned GO TO
Arithmetic IF
Block IF / ELSE IF
ELSE
END IF
RETURN
STOP
END
DO / DO WHILE
If the terminal statement is a logical IF statement, it can contain any executable statement, except:
DO / DO WHILE
Block IF / ELSE IF
ELSE
END IF
END
Logical IF
If s is not specified, the DO WHILE loop must end with an END DO statement.
The range of a DO WHILE loop consists of all the executable statements that appear following the DO WHILE statement, up to and including the terminal statement.
If a DO WHILE statement appears within the range of another DO WHILE loop, its range must be entirely contained within the range of the outer DO WHILE loop. More than one DO WHILE loop can have the same terminal statement.
If a DO WHILE statement appears within an IF, ELSE IF, or ELSE block, the range of the associated DO WHILE loop must be entirely within that block.
If a block IF statement appears within the range of a DO WHILE loop, the corresponding END IF statement must also appear within the range of that DO WHILE loop.
After the terminal statement of a DO WHILE loop is executed, control is transferred back to the corresponding DO WHILE statement.