RETURN

>>-RETURN--+------------+--;-----------------------------------><
           +-expression-+

RETURN returns control, and possibly a result, from a Rexx program, method, or internal routine to the point of its invocation.

If no internal routine (subroutine or function) is active, RETURN and EXIT are identical in their effect on the program that is run. (See EXIT.)

If a subroutine is run, expression (if any) is evaluated, control is passed back to the caller, and the Rexx special variable RESULT is set to the value of expression. If you omit expression, the special variable RESULT is dropped (becomes uninitialized). The various settings saved at the time of the CALL (for example, tracing and addresses) are also restored. (See CALL.)

If a function is processed, the action taken is identical, except that expression must be specified on the RETURN instruction. The result of expression is then used in the original expression at the point where the function was called. See the description of functions in Functions for more details.

If a method is processed, the language processor evaluates expression (if any) and returns control to the point from which the method's activating message was sent. If called as a term of an expression, expression is required. If called as a message instruction, expression is optional and is assigned to the Rexx special variable RESULT if you specify it. If the method has previously issued a REPLY instruction, the RETURN instruction must not include a result expression.

If a PROCEDURE instruction was processed within the routine (subroutine or internal function), all variables of the current generation are dropped (and those of the previous generation are exposed) after expression is evaluated and before the result is used or assigned to RESULT.

Note: If the RETURN statement causes the program to return to the operating system on a Unix/Linux system the value returned is limited to a numerical value between 0 and 255 (an unsigned byte). If no expression is supplied then the default value returned to the operating system is zero.