DO Until loop

Use the DO UNTIL statement to run the block of code until the expression is true. The contents of a DO UNTIL block will always run at least once, even if the expression is true the first time the DO statement is processed. Every time the END statement is processed the expression is evaluated again; if not true, processing returns to the DO statement for another pass through the block of code.

The condition is evaluated again at the end of each iteration of the DO/END block; if it is still not true, the block is run again.

DO UNTIL <expression>

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

For more details on REXX expressions and available functions, see TSO/E REXX Reference.

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

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

Loops of this type are protected from running forever by accident by the global loop limit. This is set by OPTIONS LIMIT, which defaults to 100.