Action taken when a condition is not trapped, Action taken when a condition is trapped – IBM SC34-5764-01 User Manual

Page 248

Advertising
background image

/* The following does not raise NOVALUE. */
signal on novalue
a.=0
say a.z
say 'NOVALUE is not raised.'
exit

novalue:
say 'NOVALUE is raised.'

You can specify this condition only for SIGNAL ON.

SYNTAX

raised if any language processing error is detected while the program is running. This includes all
kinds of processing errors, including true syntax errors and “run-time” errors, such as attempting an
arithmetic operation on nonnumeric terms. You can specify this condition only for SIGNAL ON.

Any ON or OFF reference to a condition trap replaces the previous state (ON, OFF, or DELAY, and any
trapname) of that condition trap. Thus, a CALL ON HALT replaces any current SIGNAL ON HALT (and a
SIGNAL ON HALT replaces any current CALL ON HALT), a CALL ON or SIGNAL ON with a new trap
name replaces any previous trap name, any OFF reference disables the trap for CALL or SIGNAL, and so
on.

Action Taken When a Condition Is Not Trapped

When a condition trap is currently disabled (OFF) and the specified condition occurs, the default action
depends on the condition:

v

For HALT and SYNTAX, the processing of the program ends, and a message (see Appendix A, “Error
Numbers and Messages,” on page 379)
describing the nature of the event that occurred usually
indicates the condition.

v

For all other conditions, the condition is ignored and its state remains OFF.

Action Taken When a Condition Is Trapped

When a condition trap is currently enabled (ON) and the specified condition occurs, instead of the usual
flow of control, a CALL trapname or SIGNAL trapname instruction is processed automatically. You can
specify the trapname after the NAME subkeyword of the CALL ON or SIGNAL ON instruction. If you do
not specify a trapname, the name of the condition itself (ERROR, FAILURE, HALT, NOTREADY,
NOVALUE, or SYNTAX) is used.

For example, the instruction call on error enables the condition trap for the ERROR condition. If the
condition occurred, then a call to the routine identified by the name ERROR is made. The instruction call
on error name commanderror

would enable the trap and call the routine COMMANDERROR if the

condition occurred.

The sequence of events, after a condition has been trapped, varies depending on whether a SIGNAL or
CALL is processed:

v

If the action taken is a SIGNAL, execution of the current instruction ceases immediately, the condition is
disabled (set to OFF), and the SIGNAL takes place in exactly the same way as usual (see page 164).

If any new occurrence of the condition is to be trapped, a new CALL ON or SIGNAL ON instruction for
the condition is required to re-enable it when the label is reached. For example, if SIGNAL ON SYNTAX
is enabled when a SYNTAX condition occurs, then, if the SIGNAL ON SYNTAX label name is not found,
a usual syntax error termination occurs.

v

If the action taken is a CALL (which can occur only at a clause boundary), the CALL is made in the
usual way (see page 135) except that the call does not affect the special variable RESULT. If the
routine should RETURN any data, then the returned character string is ignored.

Conditions and Condition Traps

226

CICS TS for VSE/ESA: REXX Guide

Advertising