on the error that was trapped, resuming execution may or may
not be possible.
For additional information on error trapping, see the error
functions ERFt$, EL and ER, described in Chapter V, BASIC 7.0
Encyclopaedia.
Program Tracing—TRON and TROFF Commands
When a problem in a program occurs, or you do not get the
results you expect, it can be useful to methodically work through
the program and do exactly what the computer would do. This
process is called tracing. Draw variable boxes and update the
values according to the program statements. Perform
calculations and print results following each instruction.
Tracing may show you, for example, that you have used a GOTO
with an incorrect line number, or calculated a result but never
stored it in a variable. Many program errors can be located by
pretending to be the computer, and following only one instruction
at a time. Your C128 can perform a type of trace using the
special commands TRON and TROFF (short for TRace ON and
TRace OFF). When the program is run, with TRACE ON the
computer prints the line numbers in the order they are executed.
ln this way, you may be able to see why your program is not
giving the results you expected.
Type any short program we have used so far, or use one of your
own design. To activate trace mode, type TRON in DIRECT
mode. When you run the program, notice how line numbers
appear in brackets before any results are displayed. Try to follow
the line numbers and see how many steps the computer needed
to arrive at a certain point. TRON will be more interesting if you
pick a program with many branches, such as GOTO, GOSUB
and IF-THEN-line number. Type TROFF to turn trace mode off
before continuing.
You do not have to trace an entire program. You can place
TRON within a program as a line prior to the program section
causing problems. Put the word TROFF as a program line after
the troublesome section. When you run the program, only the
lines between TRON and TROFF will be bracketed in the results.
5-13