LEAVE causes an immediate exit from one or more repetitive DO loops (that is, any DO construct other than a simple DO).>>-LEAVE--+------+--;------------------------------------------>< '-name-'
Processing of the group of instructions is ended, and control is passed to the instruction following the END clause, just as though the END clause had been encountered and the termination condition had been met. However, on exit, the control variable (if any) will contain the value it had when the LEAVE instruction was processed.
The name is a symbol, taken as a constant. If name is not specified, LEAVE ends 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), and that loop (and any active loops inside it) is then ended. Control then passes to the clause following the END that matches the DO clause of the selected loop.
do i=1 to 5
say i
if i=3 then leave
end
/* Displays the numbers: "1" "2" "3" */