2.4.6 The EXIT Instruction
      EXIT [ expr ] ;

Terminates the REXX program, and optionally returns the expression
expr to the caller. If specified, expr can be any string.  In some
systems, there are restrictions on the range of valid values for
the expr. Often the return expression must be an integer, or even
a non-negative integer.  This is not really a restriction on the
REXX language itself, but a restriction in the environment in
which the interpreter operates, check the system dependent
documentation for more information.

If expr is omitted, nothing will be returned to the caller.  Under
some circumstances that is not legal, and might be handled as an
error or a default value might be used. The EXIT instruction
behaves differently in a “program” than in an external subroutine.
In a “program”, it returns control to the caller e.g. the
operating system command interpreter.  While for an external
routine, it returns control to the calling REXX script,
independent of the level of nesting inside the external routine
being terminated.

                            RETURN           EXIT
At the main level of the    Exits program    Exits program
program

At an internal subroutine   Exits            Exits program
level of the program        subroutine, and
                            returns to
                            caller

At the main level of an     Exits the        Exits the
external subroutine         external         external
                            subroutine       subroutine

At a subroutine level       Exits the        Exits the
within an external          subroutine,      external
subroutine                  returning to     subroutine
                            calling routine
                            within external
                            subroutine
                            script

              Actions of RETURN and EXIT Instructions

If terminating an external routine (i.e. returning to the calling
REXX script) any legal REXX string value is allowed as a return
value. Also, no return value can be returned, and in both cases,
this information is successfully transmitted back to the calling
routine.  In the case of a function call (as opposed to a
subroutine call), returning no value will raise SYNTAX condition
{44}. The table above describes the actions taken by the EXIT and
RETURN instruction in various situations.



PREV NEXT