The ERR(#) function was part of the original AlphaBASIC, but A-Shell adds two new sub-functions, ERR(8) and ERR(9). For completeness, all the sub-functions are documented in the table below:
|
Sub-Function |
Description |
|
ERR(0) |
Returns the last Basic error code. See SYS:ERRMSG.xxx for the description of all the Basic error codes. Also see ERRMSG.SBR for info on displaying and/or logging the error text under application control. |
|
ERR(1) |
Returns the last line number processed. Note that since A-Shell Basic doesn't require line numbers on every line, the last line number processed might be a long way from where the error occurred (or it may be 0 if the program has no line numbers). See ERR(8) to get the precise location of the error. |
|
ERR(2) |
Returns the last file channel processed. See FILNAM.SBR for info on retrieving the name of the file associated with the channel. |
|
ERR(8) |
(A-Shell Extension) Returns the internal location counter where the error occurred. Note that by convention, location counter values are usually displayed in hex, but the Basic PRINT statement has no way to know (or support) this. So if you are going to print the value of err(8), you may want to use MIAMEX, MX_OCVT (in the XCALL Ref), or the Fn'Dec2Hex$() function (in the SOSLIB). To match the location with a line of source code, you'll need to compile your program with the /L switch to create a LSX file, which lists the location counter (in hex) for each statement. |
|
ERR(9) |
(A-Shell Extension) Returns the function or procedure nesting level at the time of the error (equivalent to the dot variable .NEST_LEVEL). This might be helpful in debugging. |
If you add TRACE=BASERR to the miame.ini (highly recommended), then all BASIC errors will be logged to the ashlog.log file, including most of the above information, and indicating whether the error was trapped.
Errors occurring within User-defined Functions or Procedures will appear to the calling routine to have occurred on the line in which the Function or Procedure was invoked, unless the Function/Procedure performs its own local error trapping.