CHAPTER 4

ERROR HANDLING

If you enter improper instructions, syntax, or formats, BASIC-80 issues an error message. This chapter explains what these errors mean, how they may be trapped with the ON ERROR statement and pinpointed with the TRON, TROFF, ERR, and ERL instructions, and how errors may be simulated with the ERROR statement.

BASIC-80 Error Messages

When BASIC-80 encounters an error in a program, it displays an error message. Appendix A lists the error messages and error codes, and describes their meaning. These errors stop program execution. You can use the BASIC-80 editor at this point to correct obvious errors, add error-trapping instructions, or use the trace facility.

Syntax Error Messages

If BASIC-80 detects a syntax error, it stops program execution, displays an error message, and enters the Edit Mode:

10LET A=

20PRINT A RUN

SYNTAX ERROR IN 10

10

You can now change line 10, as described in Chapter 3. To leave the Edit Mode without making any changes, and to preserve the variable values in the program, type Q. If you enter any other editing subcommands (including Carriage Return) variable values are lost.

Overflow, Underflow, and Divide-by-Zero

In BASIC-80, the single- and double-precision floating-point overflow, underflow, and divide-by-zero errors do not halt program execution.

Overflow. Single-precision floating-point overflow occurs when the magnitude of a single-precision numeric value exceeds (±) 3.4 x 1038 (3.4E38). Double-precision floating-point overflow occurs when the magnitude of a double-precision numeric value exceeds (±) 1.79 x 10308 (1.79D308). When a value of this magnitude is generated, the message OVERFLOW is displayed, a value equal to the largest possi- ble magnitude for the given representation with the appropriate sign is assigned, and

ex~cution proceeds.

The following examples show single- and double-precision overflow:

10 A = 1E20*1 E20

20D# = 1D200*1 D200

30PRINT A;D#

RUN OVERFLOW

OVERFLOW

3.402824E + 38 1.79769313486231 D+308

4-1

Page 29
Image 29
Intel 9800758-02 manual BASIC-80 Error Messages, Syntax Error Messages, Overflow, Underflow, and Divide-by-Zero