The exceptions described up to now have all been generated internally by the ICL system, or in the case of CTRLC are initiated by the user. It is also possible for ICL procedures to generate exceptions, which may be used to indicate error conditions. This is done by using the SIGNAL command. This has the form
SIGNAL name text
where name is the name of the exception, and text is the message text
associated with the exception. The exception name may be any valid ICL
identifier. Exceptions generated by SIGNAL work in exactly the same way
as the standard exceptions listed in appendix C. An exception handler
will be executed if one exists, otherwise an error message will be output
and ICL will return to direct mode.
One use of the SIGNAL command is as a means of escaping from deeply nested loops. The BREAK statement can be used to exit from a single loop but is not applicable if two or more loops are nested. In these cases the following structure could be used
LOOP
LOOP
LOOP
.
IF FINISHED
SIGNAL ESCAPE
END IF
.
END LOOP
END LOOP
END LOOP
EXCEPTION ESCAPE
END EXCEPTION
where the exception handler again contains no statements, but simply exists to cause normal procedure exit, rather than an error message when the exception is signalled.
ICL The Interactive Command Language for ADAM