A special variable can be set automatically during processing of a Rexx program. There are five special variables:
is set to the return code from any executed command (including those submitted with the ADDRESS instruction). After the trapping of ERROR or FAILURE conditions, it is also set to the command return code. When the SYNTAX condition is trapped, RC is set to the syntax error number (1-99). RC is unchanged when any other condition is trapped.
Note: Commands executed manually during interactive tracing do not change the value of RC.
is set by a RETURN instruction in a subroutine that has been called, or a method that was activated by a message instruction, if the RETURN instruction specifies an expression. (See EXIT, REPLY, and RETURN.) If the RETURN instruction has no expression, RESULT is dropped (becomes uninitialized). Note that an EXIT or REPLY instruction also sets RESULT.
is set when a method is activated. Its value is the object that forms the execution context for the method (that is, the receiver object of the activating message). You can use SELF to:
Run a method in an object in which a method is already running. For example, a Find_Clues method is running in an object called Mystery_Novel. When Find_Clues finds a clue, it sends a Read_Last_Page message to Mystery_Novel:
Pass references about an object to the methods of other objects. For example, a Sing method is running in object Song. The code Singer2~Duet(self) would give the Duet method access to the same Song.
is set to the line number of the last instruction that caused a transfer of control to a label (that is, any SIGNAL, CALL, internal function call, or trapped condition). See The Special Variable SIGL.
is set when a method is activated. Its value is the class object that is the usual starting point for a superclass method lookup for the SELF object. This is the first immediate superclass of the class that defined the method currently running. (See Classes and Instances.) If the current method was defined by a class in the direct inheritance chain, SUPER will always refer to the immediate superclass that class. If the current method is defined by a mixin class, the SUPER variable will always be the superperclass of the mixin class.
The special variable SUPER lets you call a method in the superclass of an object. For example, the following Savings class has INIT methods that the Savings class, Account class, and Object class define.
::class Account ::method INIT expose balance use arg balance self~init:super /* Forwards to the Object INIT method */ ::method TYPE return "an account" ::method name attribute ::class Savings subclass Account ::method INIT expose interest_rate use arg balance, interest_rate self~init:super(balance) /* Forwards to the Account INIT method */ ::method type return "a savings account"
When the INIT method of the Savings class is called, the variable SUPER is set to the Account class object. The instruction:
self~init:super(balance) /* Forwards to the Account INIT method */
calls the INIT method of the Account class rather than recursively calling the INIT method of the Savings class. When the INIT method of the Account class is called, the variable SUPER is assigned to the Object class.
self~init:super /* Forwards to the Object INIT method */
calls the INIT method that the Object class defines.
You can alter these variables like any other variable, but the language processor continues to set RC, RESULT, and SIGL automatically when appropriate. The EXPOSE, PROCEDURE, USE and DROP instructions also affect these variables.
Rexx also supplies functions that indirectly affect the execution of a program. An example is the name that the program was called by and the source of the program (which are available using the PARSE SOURCE instruction). In addition, PARSE VERSION makes available the language version and date of Rexx implementation that is running. The built-in functions ADDRESS, DIGITS, FUZZ, FORM, and TRACE return other settings that affect the execution of a program.