Previous Next Chapter

Interrupts

ARexx maintains an internal interrupt system used to detect and trap certain error conditions. When an interrupt is enabled and its corresponding condition arises, a transfer of control to the label specific it that interrupt occurs. This allows a program to retain control in circumstances that might otherwise cause the program to terminate. The interrupt conditions can be caused by either synchronous events, like a syntax error, or asynchronous events, like a Ctrl+C break request.

Note:

The name assigned to each interrupt is actually the label to which control will be transferred. Thus, a SYNTAX interrupt will transfer control to the label "SYNTAX:". Interrupts can be enabled or disabled using the SIGNAL instruction. For example, the instruction "SIGNAL ON SYNTAX" would enable the SYNTAX interrupt.

The interrupts supported by ARexx are:

BREAK_C

BREAK_D

BREAK_E

BREAK_F

ERROR

HALT

IOERR

NOVALUE

SYNTAX

When an interrupt forces a transfer of control, all of the currently active control ranges are dismantled and the interrupt that caused the transfer is disabled. This disabling prevents a possible recursive interrupt loop. Only the control structures in the current environment are affected, so an interrupt generated within a function will not affect the caller's environment.

Two special variables are affected when an interrupt occurs:

SIGL

RC

Interrupts are useful for error-recovery actions. This involves informing external programs that an error occurred or reporting further diagnostics to isolate the problem. Program 15 issues a "message" command to an external host called "MyEdit" whenever a syntax error is detected.

Program 15. Interrupt.rexx

/*A macro program for `MyEdit `*/
SIGNAL ON SYNTAX /*Enable interrupt*/
(normal processing)
EXIT
SYNTAX: /*Syntax error detected*/`
ADDRESS `MyEdit'
`message' `error' RC errortext (RC)
EXIT 10

Top Previous Next Chapter