────LEAVE────┬────────┬────;──────────────── └──name──┘
LEAVE is used to cause an immediate exit from one or more repetitive DO loops (that is, any DO construct other than a simple DO loop).
Processing of the group of instructions is terminated, and control is passed to the instruction following the END clause as though the END clause had been encountered and the termination condition had been met normally. However, on exit, the control variable, if any, will contain the value it had when the LEAVE instruction was processed.
If name is not specified, LEAVE terminates the innermost active repetitive loop. If name is specified, it must be the name of the control variable of a currently active loop which may be the innermost loop; that loop (and any active loops inside it) is then terminated. Control then passes to the clause following the END clause that matches the DO clause of the selected loop.
Example:
do i=1 to 5 say i if i=3 then leave end /* Would display the numbers: 1, 2, 3 */
Notes: