Skip to main content

Software > Software Development > IBM REXX Family >

NetRexx

Technical detail

Leave instruction

leave [name];

where name is a non-numeric symbol.

leave causes immediate exit from one or more do, loop, or select constructs. It may only be used in the body (the first instructionlist) of the construct.

Execution of the instruction list is terminated, and control is passed to the end clause of the construct, just as though the last clause in the body of the construct had just been executed or (if a loop) the termination condition had been met normally, except that on exit the control variable (if any) will contain the value it had when the leave instruction was executed.

If no name is specified, then leave must be within an active loop and will terminate the innermost active loop.

If a name is specified, then it must be the name of the label (or control variable for a loop with no label), of a currently active do, loop, or select construct (which may be the innermost). That construct (and any active constructs inside it) is then terminated. Control then passes to the clause following the end clause that matches the do, loop, or select clause identified by the name.

Example:

  loop i=1 to 5
say i
if i=3 then leave
end i
/* Would display the numbers: 1, 2, 3 */

Notes:

  1. If any construct being left includes a finally clause, the instructionlist following the finally will be executed before the construct is left.
  2. A do, loop, or select construct is active if it is currently being executed. If a method (even in the same class) is called during execution of an active construct, then the construct becomes inactive until the method has returned. leave cannot be used to leave an inactive construct.
  3. The name symbol, if specified, must exactly match the label (or the name of the control variable, for a loop with no label) in the do, loop, or select clause in all respects except case.

 

 

PreviousTable of contents Next
We're here to help
Easy ways to get the answers you need.
E-mail us

or call us at
877-426-3774
Priority code:
104CBW67