The Computer Tutor: TS 2068 Error Trapping

The Computer Tutor heading art, tutor in mortarboard pointing at a computer
The Computer Tutor heading art, tutor in mortarboard pointing at a computer

Good morning Class! In the last tutorial, we discussed a method of utilizing the last two lines on the screen of the TS-2068. When trying to develop a program that could easily self-destruct and render the keyboard inoperative, it would be nice if we could develop a program routine that would do just that.

Let us suppose that we were writing a program with some fancy POKEs or M/C routines. In most cases we would have to constantly save up-graded versions on tape before we test them – otherwise, a crash would cause all our entry to be lost.

The ON ERR command is unique and very useful. It can direct the program to a different part of the listing wheree the error can be easily controlled.

Let us say that our program had the POKE 23659,0 in it as discussed in last month’s issue. The commands CLS or PRINT AT 23,n (where n = 0 to 31) would cause an un-recoverable crash. If we started our program with:

1 ON ERR GOTO 9900

the program (in most cases) would be directed to line #9900 whenever an error situation occurs (even if the BREAK keys are pressed). This, however, does not solve the problem completely. The keyboard may still be hung up with all sorts of weird graphics on the screen. What we need to do now is to write a routine starting with line #9900 that will not only restore the critical memory locations with safe numbers but to also locate the line in question where the error occured. The following routine will accomplish this:

9900 POKE 23659,2
9910 ON ERR RESET
9920 CLS
9930 PRINT "ERROR IS IN
LINE #";PEEK 23736
+ 256 * PEEK 23737
9940 PRINT,, "ERROR #";
PEEK 23739
9950 PRINT "IN STATEMENT
#";PEEK 23738

To explain what this routine does, 9900 resets the bottom two screen lines to allow the INPUT command to work. Line 9910 disables the error trapping mode so that the keyboard is operative. Line 9920 clears the screen and line 9930 traps the actual line that the error occured in. Line 9940 gives the report code of the type of error (page 288 manual) and line 9950 states in which command statement or section of that line, the error occured.

To test this routine, add the following lines:

100 PRINT AT 0,0; "WHAT IS
YOUR NAME?": INPUT N$
110 CLS: POKE 23659,0
120 PRINT AT 22,0:PRINT
"WELL, "HELLO THERE ";
N$
130 PAUSE 40000: POKE
23659,2
:CLS
140 GOTO 100

First save the program and then test it. Try changing the 23659 POKEs to different line numbers or eliminating them all together. Press the BREAK keys and see what happens.

If CLS is encountered with location 23659 holding a 0, the ON ERR command won’t work. The same occurs if PRINT AT 23,n occurs.

The 2068 has error trapping built in which sometimes doesn’t work by itself. Hopefully, this method will help.

Class dismissed!

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.