Error conditions and other unexpected events are referred to as Exceptions in ICL. When such a condition is detected in direct mode a message is output. For example, if we enter a statement which results in an error
ICL> =SQRT(-1)
SQUROONEG Square Root of Negative Number
ICL>
We get a message consisting of the name of the exception (SQUROONEG) and a description of the nature of the exception. A full list of ICL exceptions is given in appendix C.
If the error occurs within a procedure the message contains a little more information. As an example, if we use our square root procedure of chapter 3 with an invalid value we get the following messages:
ICL> SQUARE_ROOT (-1)
SQUROONEG Square Root of Negative Number
In Procedure: SQUARE_ROOT
At Statement: PRINT The Square Root of (X) is (SQRT(X))
ICL>
If one procedure is called by another, the second procedure will also be listed in the error message. If we run the following procedure
PROC TABLE
{ Print a table of Square roots from 5 down to -5 }
LOOP FOR I = 5 TO -5 STEP -1
SQUARE_ROOT (I)
END LOOP
END PROC
we get
ICL> TABLE
The Square Root of 5 is 2.236068
The Square Root of 4 is 2
The Square Root of 3 is 1.732051
The Square Root of 2 is 1.414214
The Square Root of 1 is 1
The Square Root of 0 is 0
SQUROONEG Square Root of Negative Number
In Procedure: SQUARE_ROOT
At Statement: PRINT The Square Root of (X) is (SQRT(X))
Called by: TABLE
ICL>
ICL The Interactive Command Language for ADAM