OS/2 Procedures Language 2/REXX


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


LEAVE




 >>----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: 
   1. If specified, name must match the one on the DO instruction 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 during 
      execution of a loop, a subroutine is called or an INTERPRET 
      instruction is processed, the loop becomes inactive until the 
      subroutine has returned or the INTERPRET instruction has completed. 
      LEAVE cannot be used to terminate an inactive loop. 
   3. If more than one active loop uses the same control variable, the 
      innermost one is the one selected by LEAVE. 
   

Inf-HTML End Run - Successful