EXIT Instruction
The EXIT instruction causes a REXX program to unconditionally end and return to where the program was called. If another program called the REXX program, EXIT returns to that calling program. More about calling external routines appears later in this chapter and in Writing Subroutines and Functions . For more detailed information on the EXIT instruction, see section EXIT.
Besides ending
a program
, EXIT can also return a value to the caller
of the
program
. If the
program
was called as a subroutine from another
REXX
program
, the value is received in the REXX special variable RESULT.
If the
program
was called as a function, the value is received in the
original expression at the point where the function was called. Otherwise,
the value is received in the REXX special variable RC.
The value can represent a return code and can be in the form of
a constant or an expression that is computed.
Figure 1. Example
Using the EXIT Instruction
/******************************** REXX
****************************/
/* This
program
uses the EXIT instruction to end the
program
and */
/* return a value indicating whether a job applicant gets the */
/* job. A value of 0 means the applicant does not qualify for */
/* the job, but a value of 1 means the applicant gets the job. */
/* The value is placed in the REXX special variable RESULT. */
/******************************************************************/
PULL months_experience /* Gets number from input stream */
PULL references /* Gets "Y" or "N" from input stream */
PULL start_tomorrow /* Gets "Y" or "N" from input stream */
IF (months_experience > 24) & (references = 'Y') &
(start_tomorrow= 'Y')
THEN job = 1 /* person gets the job */
ELSE job = 0 /* person does not get the job */
EXIT job