Because these conditions (ERROR, FAILURE, and HALT) can arise during execution of an INTERPRET
instruction, execution of the INTERPRET may be interrupted and later resumed if CALL ON was used.
As the condition is raised, and before the CALL is made, the condition trap is put into a delayed state.
This state persists until the RETURN from the CALL, or until an explicit CALL (or SIGNAL) ON (or OFF)
is made for the condition. This delayed state prevents a premature condition trap at the start of the
routine called to process a condition trap. When a condition trap is in the delayed state it remains
enabled, but if the condition is raised again, it is either ignored (for ERROR, FAILURE, or NOTREADY)
or (for the other conditions) any action (including the updating of the condition information) is delayed
until one of the following events occurs:
1. A CALL ON or SIGNAL ON, for the delayed condition, is processed. In this case a CALL or SIGNAL
takes place immediately after the new CALL ON or SIGNAL ON instruction has been processed.
2. A CALL OFF or SIGNAL OFF, for the delayed condition, is processed. In this case the condition trap
is disabled and the default action for the condition occurs at the end of the CALL OFF or SIGNAL
OFF instruction.
3. A RETURN is made from the subroutine. In this case the condition trap is no longer delayed and the
subroutine is called again immediately.
On RETURN from the CALL, the original flow of execution is resumed (that is, the flow is not affected
by the CALL).
Notes:
1. You must be extra careful when you write a syntax trap routine. Where possible, put the routine
near the beginning of the program. This is necessary because the trap routine label might not be
found if there are certain scanning errors, such as a missing ending comment. Also, the trap routine
should not contain any statements that might cause more of the program in error to be scanned.
Examples of this are calls to built-in functions with no quotation marks around the name. If the
built-in function name is in uppercase and is enclosed in quotation marks, REXX goes directly to the
function, rather than searching for an internal label.
2. In all cases, the condition is raised immediately upon detection. If SIGNAL ON traps the condition,
the current instruction is ended, if necessary. Therefore, the instruction during which an event occurs
may be only partly processed. For example, if SYNTAX is raised during the evaluation of the
expression in an assignment, the assignment does not take place. Note that the CALL for ERROR,
FAILURE, HALT, and NOTREADY traps can occur only at clause boundaries. If these conditions
arise in the middle of an INTERPRET instruction, execution of INTERPRET may be interrupted and
later resumed. Similarly, other instructions, for example, DO or SELECT, may be temporarily
interrupted by a CALL at a clause boundary.
3. The state (ON, OFF, or DELAY, and any trapname) of each condition trap is saved on entry to a
subroutine and is then restored on RETURN. This means that CALL ON, CALL OFF, SIGNAL ON,
and SIGNAL OFF can be used in a subroutine without affecting the conditions set up by the caller.
See the CALL instruction (page 135) for details of other information that is saved during a
subroutine call.
4. The state of condition traps is not affected when an external routine is called by a CALL, even if the
external routine is a REXX program. On entry to any REXX program, all condition traps have an
initial setting of OFF.
5. While user input is processed during interactive tracing, all condition traps are temporarily set OFF.
This prevents any unexpected transfer of control—for example, should the user accidentally use an
uninitialized variable while SIGNAL ON NOVALUE is active. For the same reason, a syntax error
during interactive tracing does not cause exit from the program but is trapped specially and then
ignored after a message is given.
6. The system interface detects certain execution errors either before execution of the program starts
or after the program has ended. SIGNAL ON SYNTAX cannot trap these errors.
Note that a label is a clause consisting of a single symbol followed by a colon. Any number of
successive clauses can be labels; therefore, multiple labels are allowed before another type of clause.
Conditions and Condition Traps
Chapter 17. Conditions and Condition Traps 227