IBM SC34-5764-01 Server User Manual


 
LEAVE
Purpose
 LEAVE
name
; 
LEAVE causes an immediate exit from one or more repetitive DO loops (that is, any DO construct other
than a simple DO).
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.
Example:
do i=1 to 5
say i
if i=3 then leave
end
/* Displays the numbers: "1" "2" "3" */
Notes:
1. If specified, name must match the symbol naming the control variable in the DO clause in all respects
except case. No substitution for compound variables is carried out when the comparison is made.
2. A loop is active if it is currently being processed. If a subroutine is called (or an INTERPRET
instruction is processed) during execution of a loop, the loop becomes inactive until the subroutine has
returned or the INTERPRET instruction has completed. LEAVE cannot be used to end an inactive loop.
3. If more than one active loop uses the same control variable, LEAVE selects the innermost loop.
LEAVE
148
CICS TS for VSE/ESA: REXX Guide