
Chapter 9. Event Polling and Error/Event Trapping
149
9.3 Error Trapping
[ 1 ] Overview
If a run-time error occurs during program running, error trapping makes the program cause an
interrupt upon completion of the machine instruction so as to transfer control from the current
program to the error-handling routine which has been specified by a label.
If a run-time error occurs when this trapping ability is disabled, the Interpreter will terminate the
current user program while displaying the error message as shown below.
Error message sample:
The above message indicates that a run-time error has occurred at address 38A4h and its
error code is 34h. Both the address and error code are expressed in hexadecimal notation.
The address is a relative address and corresponds to the address in the program list outputted
by the Compiler. According to this address indication, you can pinpoint the program line where
the run-time error has occurred.
The error code 34h (52 in decimal notation) means that the user program attempted to access
a file not opened. (Refer to Appendix A1, "Run-time Errors.")
The
ERL
and
ERR
functions described in an error-handling routine will return the same values,
38A4h and 34h, respectively.
NOTE
If an error occurs during execution of user-defined functions or subroutines so that
the error is trapped and handled by the error-handling routine, then do not directly
pass control back to the main routine having the different stack level by using the
RESUME
statement. The return address from the user-defined functions or subrou-
tines will be left on the stack, causing a run-time error due to stack overflow.
To prevent such a problem, once transfer control to the routine which caused the
interrupt in order to match the stack level and then jump to any other desired routine.
(Refer to Chapter 3, Section 3.1, "Program Overview.")
ERL=38A4
ERR=0034
Содержание BHT-BASIC 100 SERIES
Страница 1: ......
Страница 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Страница 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Страница 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Страница 192: ...Chapter 14 Statement Reference 184 Example OPEN master Dat AS 1 FIELD 1 20 AS bar 10 AS ky CLFILE 1 CLOSE 1...
Страница 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...
Страница 349: ...341 Run time errors Error code Meaning 05h Parameter out of the range checktype is out of the range...
Страница 383: ...375 Run time errors Reference Error code Meaning 05h Parameter out of the range Functions LEFT LEN and RIGHT...