Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕ES Error simulate
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕ES Error simulate


One-argument form

⎕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

Two-argument form

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

Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕ES Error simulate
[ Previous | Next | Contents | Index | APL Home ]