The range of a DO construct includes all the statements and constructs that follow the DO statement, up to and including the terminal statement. If the DO construct contains another construct, the inner (nested) construct must be entirely contained within the DO construct.
Execution of a DO construct differs depending on how the loop is controlled, as follows:
For simple DO constructs, there is no loop control. Statements in the DO range are repeated until the DO statement is terminated explicitly by a statement within the range.
For iterative DO statements, loop control is specified as do-var = expr1, expr2 [,expr3]. An iteration count specifies the number of times the DO range is executed. (For more information, see Iteration Loop Control.)
For DO WHILE statements, loop control is specified as a DO range. The DO range is repeated as long as a specified condition remains true. Once the condition is evaluated as false, the DO construct terminates. (For more information, see the DO WHILE statement.)