ŒES can simulate a predetermined or programmer-defined error, in a form compatible with IBM's APL2. If the right argument is a character vector or scalar, ŒET is set to 0 1 and the right argument is used as the error message. A two element integer right argument will generate the appropriate error message (if the argument corresponds to a valid value for ŒET) or no error message (if there is no corresponding value for ŒET). An empty vector right argument causes no action to be taken, whilst a right argument of 0 0 resets error messages and codes (ŒEM ŒERM ŒET ŒLER).
’R„A DIVIDE B
[1] ŒES(B=0)/'ATTEMPT TO DIVIDE BY ZERO'
[2] R„A÷B
’ 1.43.05 05/28/90
3 DIVIDE 0
ATTEMPT TO DIVIDE BY ZERO (Message displayed)
3 DIVIDE 0
^
ŒET (ŒET set to 0 1)
0 1
ŒLER (1†ŒLER set to 15 - unknown error)
15 0
’R„A DIVIDE B
[1] ŒES(B=0)/5 4 (Signal the standard error)
[2] R„A÷B
’ 1.44.32 05/28/90
5 DIVIDE 0
DOMAIN ERROR (Standard message shown)
5 DIVIDE 0
^
ŒET (Standard values for ŒET, ŒLER)
5 4
ŒLER
11 0
Using an argument to ŒES that does not correspond to a error code of ŒET causes no error message to display.
’DOIT
[1] ŒES 101 45 (Outside the ŒET range)
’ 1.45.48 05/28/90
DOIT
DOIT (No error message displayed)
^
ŒET (ŒET takes chosen value)
101 45
ŒLER (ŒLER takes ¯1 value)
¯1 0
The two-argument form of ŒES can be used to signal both an Error Type and an Error Message. The left argument should be a character scalar or vector which will be used as the error message portion of ŒEM and ŒERM and the right argument should be a two element integer vector which will be assigned to ŒET. The left argument overrides the usual error message associated with a given value of ŒET. If the right argument is empty, no error is signalled. If it is 0 0 any left argument is ignored and error messages and reports are reset (ŒET ŒLER ŒEM ŒERM).
’R„A DIVIDE B
[1] ŒES(B=0)/5 4
[2] R„A÷B
’ 1.32.25 05/29/90
3 DIVIDE 0 (Standard error message)
DOMAIN ERROR
3 DIVIDE 0
^
ŒET (Standard error codes)
5 4
ŒLER
11 0
’R„A DIVIDE B
[1] 'ATTEMPT TO DIVIDE BY ZERO' ŒES(B=0)/5 4
[2] R„A÷B (Redefined error message)
’ 1.33.27 05/29/90
3 DIVIDE 0
ATTEMPT TO DIVIDE BY ZERO (New error message)
3 DIVIDE 0
^
ŒET (Standard ŒET)
5 4
ŒLER
11 0