Kilowatt Software's
Classic Rexx Tutorial
Language Level 4.00 (TRL-2)

Exit instruction

The exit instruction concludes the processing of the current procedure, and all procedures that are in progress within the current source file. If the topmost program in this source file was an external procedure, then processing continues with the instruction that called the external procedure as a subroutine or function. The value of valueExpression is optionally returned to the calling context. This value is assigned to the special RESULT variable, if the external procedure was invoked by a call instruction. If the exit instruction does not have an associated value, the RESULT variable is dropped instead. If the topmost program in this source file was a main procedure, then processing of all Rexx programs is concluded, and the value of valueExpression is returned as the overall completion code.

Return instruction

The return instruction concludes the processing of the current procedure. Processing continues with the instruction that called the procedure as a subroutine or function. The value of valueExpression is optionally returned to the calling context. This value is assigned to the special RESULT variable, if the procedure was invoked by a call instruction. If the return instruction does not have an associated value, the RESULT variable is dropped instead.

Insight: if the end of the source file is inadvertantly reached, then an implicit exit instruction without a valueExpression is performed.

Warning: execution can inadvertently flow into a procedure instruction, this will cause error code 17 (unexpected procedure) to be raised. This problem is generally corrected by preceding the label(s) of the procedure with a return or exit instruction.

When execution inadvertently flows into a procedure that lacks a procedure instruction an unexpected procedure WILL NOT be raised. This can lead to a variety of unexpected consequences. When this type of procedure is initially created you are strongly advised to precede the associated label(s) with an return or exit instruction.


Kilowatt Software's -- Classic Rexx Tutorial -- Back to top
Click here if you have any comments or questions regarding this tutorial

Last updated on: 31 Aug 2002