>>-SIGNAL--+-labelname---------------------------+--;---------->< +-+-------+--expression---------------+ | '-VALUE-' | +-OFF--+-ERROR---+--------------------+ | +-FAILURE-+ | | +-HALT----+ | | +-NOVALUE-+ | | '-SYNTAX--' | '-ON--+-ERROR---+--+----------------+-' +-FAILURE-+ '-NAME--trapname-' +-HALT----+ +-NOVALUE-+ '-SYNTAX--'
SIGNAL causes an unusual change in the flow of control (if you specify labelname or VALUE expression), or controls the trapping of certain conditions (if you specify ON or OFF).
To control trapping, you specify OFF or ON and the condition you want to trap. OFF turns off the specified condition trap. ON turns on the specified condition trap. All information on condition traps is contained in Conditions and Condition Traps.
To change the flow of control, a label name is derived from labelname or taken from the result of evaluating the expression after VALUE. The labelname you specify must be a literal string or symbol that is taken as a constant. If you use a symbol for labelname, the search is independent of alphabetic case. If you use a literal string, the characters should be in uppercase. This is because the language processor translates all labels to uppercase, regardless of how you enter them in the program. Similarly, for SIGNAL VALUE, the expression must evaluate to a string in uppercase or the language processor does not find the label. You can omit the subkeyword VALUE if expression does not begin with a symbol or literal string (that is, if it starts with a special character, such as an operator character or parenthesis). All active pending DO, IF, SELECT, and INTERPRET instructions in the current routine are then ended (that is, they cannot be resumed). Control then passes to the first label in the program that matches the given name, as though the search had started from the top of the program.
Signal fred; /* Transfer control to label FRED below */
....
....
Fred: say 'Hi!'
When control reaches the specified label, the line number of the SIGNAL instruction is assigned to the special variable SIGL. This can aid debugging because you can use SIGL to determine the source of a transfer of control to a label.
For information about using SIGNAL with the INTERPRET instruction, see Note 1.
fred='PETE'
call multiway fred, 7
....
....
exit
Multiway: procedure
arg label . /* One word, uppercase */
/* Can add checks for valid labels here */
signal value label /* Transfer control to wherever */
....
Pete: say arg(1) '!' arg(2) /* Displays: "PETE ! 7" */
return