DO While loop

Use the DO WHILE statement to run the block of code while the expression is true. If the expression is untrue when the DO WHILE statement is processed for the first time, the contents of the DO|END block are not run, and processing continues from the command after the END statement.

The condition is evaluated again at the end of each iteration of the DO|END block, and if still true the block is run again.

DO WHILE <expression>

where:
<expression>
A REXX-based expression. The expression can be any valid REXX expression that results in 1 or 0.

For more details about the REXX expressions and available functions, see the TSO/E REXX Reference manual.

For example:
VARSET X = 1
DO WHILE “!X” < 10
   DISPLAY !X
   VARSET X DELTA(1)
END

Use the ITERATE command at any point in the block to start the next iteration of the currently active loop from the DO statement again. Use the LEAVE command to exit the currently active loop and resume processing following the corresponding END statement. The ITERATE and LEAVE commands can be used only to exit the currently active block.

Loops of this type are protected from running forever by accident by the global loop limit OPTIONS LIMIT, whose default is 100.