40 END

50 MODE 7

60 PRINT"Error number ";ERR;" at Line ";ERL

70 END

This program contains a major error - there is no procedure called

PROCmain _program! Running the program gives this result:

Error number 29 at Line 30

The ON ERROR statement at line 10 tells the computer that if it finds an error

while it is running the program it should go to line 50. Every sort of error the

computer can detect has an error number, and the computer uses the variable

ERR to store this number. It uses ERL to store the line number at which the

error occurred.

The Reference Manual gives a full list of the error numbers and describes the

errors themselves in detail. However, you can get more information about the

error from the computer itself by including a REPORT statement in the

error-handling routine:

55 REPORT

60 PRINT " at Line " ;ERL

Running the program gives:

No such FN/PROC at Line 30

This shows that the computer could not find a procedure called

PROCmain_program at line 30.

You have probably already had some experience of the computer giving error

messages. As it does this automatically, you may wonder why you should

bother including an error-handling routine at all. The main reason is that the

routine can restore the computer to normal. Error messages can otherwise

prove unreadable, as you will see if you RUN this program:

10 MODE 2

20 VDU 28,19,31,19,0

30 COLOUR 135

40 a terribke mistake

50 END

Add these lines to see the advantage of an error-trapping routine:

5 ON ERROR GOTO 60

60 MODE 7

70 REPORT

80 PRINT "at Line " ;ERL

90 END

C 46