Err: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved Err to ERR)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
ERR
The '''Err''' [[internal function]] returns the [[error code]] of the most recent [[error]].
The '''Err''' [[internal function]] returns the [[error code]] of the most recent [[error]].


Line 16: Line 16:
  99960 CHAIN "MENU"
  99960 CHAIN "MENU"


ERR is also used in procedures to determine when commands are successful. In the following procedure, a PROTECT command is used to reserve a file on a multi- user system before attempting to rebuild the index for the file.
ERR is also used in procedures to determine when commands are successful. In the following procedure, a PROTECT command is used to reserve a file on a multi-user system before attempting to rebuild the index for the file.


  PROCERR RETURN
  PROCERR RETURN
Line 26: Line 26:
  CHAIN "menu"
  CHAIN "menu"


PROCERR RETURN does two important things in this procedure. It turns off normal system error processing so that the system will not stop or beep if an error occurs; also, it resets ERR to zero. After PROCERR STOP reinstates normal error processing, the SKIP command checks ERR and branches to the label DONE if ERR is no longer zero.
PROCERR RETURN does two important things in this procedure. It turns off normal system error processing so that the system will not stop or beep if an error occurs. Also, it resets ERR to zero. After PROCERR STOP reinstates normal error processing, the SKIP command checks ERR and branches to the label DONE if ERR is no longer zero.
 
====Related Functions====


====Related Functions:====
*[[Line]]
*[[Line]]


====Technical Considerations====
====Technical Considerations====
:1.) ERR is initialized to zero by the following: the RUN command, PROCERR RETURN command, CLEAR or CLEAR ALL commands and any other commands which clear memory.
 
:2.) There are three cases where errors occur and ERR is not set. First, ERR is not changed when an ON error statement (or default) has set to IGNORE the error condition corresponding to this error. Second, when the error code is 4273 (topic not found in help file), the system does not set ERR or LINE so that an error in attempting to use the HELP$ function in an error trapping routine will not affect the ability to use RETRY or CONTINUE. Third, the value of ERR is not affected when an error occurs in an immediate statement which has been keyed in from the keyboard; the error code for this immediate statement is displayed correctly in the status line.
# ERR is initialized to zero by the following: the RUN command, PROCERR RETURN command, CLEAR or CLEAR ALL commands and any other commands which clear memory.
:3.) Even when PROCERR RETURN is used in a procedure file to skip an error, the value of ERR is still set and can be tested with a SKIP command, such as SKIP 3 IF ERR=0
# There are three cases where errors occur and ERR is not set. First, ERR is not changed when an ON error statement (or default) has set to IGNORE the error condition corresponding to this error. Second, when the error code is 4273 (topic not found in help file), the system does not set ERR or LINE so that an error in attempting to use the HELP$ function in an error trapping routine will not affect the ability to use RETRY or CONTINUE. Third, the value of ERR is not affected when an error occurs in an immediate statement which has been keyed in from the keyboard; the error code for this immediate statement is displayed correctly in the status line.
:4.) ERR is affected by any error-causing string expression which is executed by a line-numbered EXECUTE statement.
# Even when PROCERR RETURN is used in a procedure file to skip an error, the value of ERR is still set and can be tested with a SKIP command, such as SKIP 3 IF ERR=0
# ERR is affected by any error-causing string expression which is executed by a line-numbered EXECUTE statement.


<noinclude>
<noinclude>

Latest revision as of 19:30, 21 May 2014

ERR

The Err internal function returns the error code of the most recent error.

Comments and Examples

Program errors which are not anticipated can be handled by adding the following to any program.

00001 ON ERROR GOTO 99900
   o
   o
99900 PRINT "Unexpected Error Number";ERR
99910 PRINT "occurred at line number";LINE
99920 PRINT
99930 PRINT "Please record this information,"
99940 PRINT "and call your dealer at once!"
99950 PAUSE
99960 CHAIN "MENU"

ERR is also used in procedures to determine when commands are successful. In the following procedure, a PROTECT command is used to reserve a file on a multi-user system before attempting to rebuild the index for the file.

PROCERR RETURN
PROTECT CUSTOMER,RESERVE
PROCERR STOP
SKIP DONE IF ERR<>0
INDEX CUSTOMER CUSTOMER.KEY 1 4 REPLACE
:DONE
CHAIN "menu"

PROCERR RETURN does two important things in this procedure. It turns off normal system error processing so that the system will not stop or beep if an error occurs. Also, it resets ERR to zero. After PROCERR STOP reinstates normal error processing, the SKIP command checks ERR and branches to the label DONE if ERR is no longer zero.

Related Functions

Technical Considerations

  1. ERR is initialized to zero by the following: the RUN command, PROCERR RETURN command, CLEAR or CLEAR ALL commands and any other commands which clear memory.
  2. There are three cases where errors occur and ERR is not set. First, ERR is not changed when an ON error statement (or default) has set to IGNORE the error condition corresponding to this error. Second, when the error code is 4273 (topic not found in help file), the system does not set ERR or LINE so that an error in attempting to use the HELP$ function in an error trapping routine will not affect the ability to use RETRY or CONTINUE. Third, the value of ERR is not affected when an error occurs in an immediate statement which has been keyed in from the keyboard; the error code for this immediate statement is displayed correctly in the status line.
  3. Even when PROCERR RETURN is used in a procedure file to skip an error, the value of ERR is still set and can be tested with a SKIP command, such as SKIP 3 IF ERR=0
  4. ERR is affected by any error-causing string expression which is executed by a line-numbered EXECUTE statement.