APLX Help : Help on APL language : System Functions & Variables : ⎕ERS Error signalling




The nomadic system function ⎕ERS ERRORNUMBER ERRORMESSAGE ⎕ERS ERRORNUMBER The ERRORNUMBER may be a vector of numbers, but the first is used as the argument. The ERRORNUMBER can be any integer, or an empty vector. The error message associated with the first number in the right argument is displayed, the calling function is halted and the first number of
An error message can be included as the left argument. If present, this is displayed instead of the normal error message associated with this number. For example, an attempt to divide by zero normally generates: 2÷0 DOMAIN ERROR 2÷0 ^ A function DIVIDE can be written which 'signals' an attempt to divide by zero, rather than stopping: ∇ R←A DIVIDE B [1] 'ATTEMPT TO DIVIDE BY ZERO' ⎕ERS (B=0)/8 [2] R←A÷B [3] ∇ 2 DIVIDE 0 DOMAIN ERROR 2 DIVIDE 0 ^ and this function can itself be used within other error trapped functions: ∇ TEST;X [1] X←⎕ERX ERR [2] START:'ENTER TWO NUMBERS ' [3] DATA←2↑⎕ ⍝MAKE SURE WE HAVE 2 NUMBERS [4] 'THE DIVISION IS:' [5] DATA[1] DIVIDE DATA[2] [6] →0 [7] ERR:→(8≠1↑⎕LER)/0 ⍝NOT ONE OF OUR ERRORS [8] 'ATTEMPT TO DIVIDE BY ZERO, TRY AGAIN' [9] →START [10] ∇ TEST ENTER TWO NUMBERS ⎕: 4 2 THE DIVISION IS: 2 TEST ENTER TWO NUMBERS ⎕: 4 0 ATTEMPT TO DIVIDE BY ZERO, TRY AGAIN ⎕: 4 4 THE DIVISION IS: 1 The use of a negative argument to ∇R←A DIVIDE B [1] ⎕ERS(B=0)/¯8 [2] R←A÷B ∇ 1.53.19 05/28/90 3 DIVIDE 0 3 DIVIDE 0 (No error message shown) ^ ⎕LER (⎕LER set to ¯8) ¯8 0 ⎕ET (⎕ET set to 0 1) 0 1 ⎕ERS 0 (Use of ⎕ERS 0 to reset error numbers) ⎕LER 0 0 ⎕ET 0 0 

APLX Help : Help on APL language : System Functions & Variables : ⎕ERS Error signalling

Copyright © 19962010 MicroAPL Ltd