AERROR( ) Function Example

The following example uses ON ERROR to specify an error handling routine named errhand. An error is generated by issuing a misspelled command (BRWS). The errhand error handling routine uses AERROR( ) to create an array containing error information, and this information is then displayed.

ON ERROR DO errhand     && errhand is the error handler procedure

BRWS  && Causes a syntax error
ON ERROR  && Restore system error handler

PROCEDURE errhand
   = AERROR(aErrorArray)  && Data from most recent error
   CLEAR
   ? 'The error provided the following information'  && Display message
   FOR n = 1 TO 7  && Display all elements of the array
      ? aErrorArray(n)
   ENDFOR