A REXX command can be stored in a variable and the variable can be interpreted to execute the command.
This feature can be used to dynamically generate the REXX command during run time and execute it.
VAR1 = "SAY 'HELLO' " INTERPRET VAR1 |
When VAR1 is interpreted the value stored in the variable is translated as a REXX command and executed. Here, the SAY command will be executed and 'HELLO' message will be displayed.
Instructions that interrupt the flow of an exec can cause the exec to:
Terminate (EXIT)
Skip to another part of the exec marked by a label (SIGNAL)
Go temporarily to a subroutine either within the exec or outside the exec (CALL/RETURN)
Interactive Interrupts
The EXIT instruction causes an exec to unconditionally end and return to where the exec was invoked. If the exec was initiated from the PROC section of an ISPF selection panel, EXIT returns to the ISPF panel. If the exec was called by a program, such as another exec, EXIT returns to the program.
The CALL instruction interrupts the flow of an exec by passing control to an internal or external subroutine. An internal subroutine is part of the calling exec. An external subroutine is another exec. The RETURN instruction returns control from a subroutine back to the calling exec and optionally returns a value.
The SIGNAL instruction, like CALL, interrupts the normal flow of an exec and causes control to pass to a specified label. The label to which control passes can appear before or after the SIGNAL instruction. Unlike CALL, SIGNAL does not return to a specific instruction to resume execution. When you use SIGNAL from within a loop, the loop automatically ends; and when you use SIGNAL from an internal routine, the internal routine will not return to its caller.
SIGNAL is useful for testing execs or to provide an emergency course of action. It should not be used as a convenient way to move from one place in an exec to another.
When a REXX s program is executed interactively, it can be interrupted by pressing ESC. On pressing ESC, the following message will appear.
ENTER HI TO END, A NULL LINE TO CONTINUE, OR AN IMMEDIATE COMMAND+ - |
The REXX program may be terminated by issuing 'HI'. This will be particularly useful when REXX gets into an infinite loop.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!