────EXIT───┬──────────────┬───;─────────────── └──expression──┘
EXIT is used to leave a program unconditionally. Optionally, EXIT returns a data string to the caller. The program is terminated immediately, even if an internal routine is currently being run. If no internal routine is active, RETURN and EXIT are identical in their effect on the program that is being run.
If you specify expression, it is evaluated and the string resulting from the evaluation is then passed back to the caller when the program terminates.
Example:
j=3 Exit j*4 /* Would exit with the string '12' */
If you do not specify expression, no data is passed back to the caller. If the program was called as an external function, this is detected as an error, either immediately (if RETURN was used), or on return to the caller (if EXIT was used).
"Running off the end" of the program is always equivalent to the EXIT instruction, in that it terminates the whole program and returns no result string.
┴╓: The language processor does not distinguish between invocation as a command on the one hand, and invocation as a subroutine or function on the other. If the program was invoked through a command interface, an attempt is made to convert the returned value to a return code acceptable by the REXX caller. The returned string must be a whole number whose value will fit in a 16-bit signed integer (within the range -2**15 to 2**15-1).