f
i
/
\
Identifying Problems in Your Programs
When a program doesn't work the way you expected, an error mes
sage usually occurs. Sometimes the messages are vague, however,
and you still don't understand the problem. The Commodore 128
computer has several ways of helping you locate the problem.
HELP
Error
TV-appfing—The
TRAP Command
The Commodore 128 provides a HELP com
mand that specifies the line in which a problem
has occurred. To actuate the HELP command,
just press the special HELP key on the row of
keys located above the main keyboard.
Type the following statement. It contains an
intentional error, so type it just as is:
10 ?3;4:5;6
When you RUN this one-line program, the com
puter prints 3 and 4 as expected, but then
responds "SYNTAX ERROR IN 10". Let's sup
pose you can't see the error (a colon instead of
a semicolon between 4 and 5). You press the
HELP key. (You can also type HELP and press
RETURN.) The computer displays the line again,
but the 5;6 is highlighted to show the error is in
that line.
Usually, if an error occurs in a program, the pro
gram "crashes" (stops running). At that point,
you can press the HELP key to track down the
error. However, you can use the BASIC 7.0
TRAP command to include an error-trapping
capability within your program. The TRAP com
mand advises you to locate and correct an error,
then resumes program operation. Usually, the
error-trapping function is set in the first line of a
program:
5 TRAP 100
tells the computer that if an error occurs to go to
a certain line (in this case, line 100). Line 100
appears at the end of the program, and sets up
USING C128 MODE—Some BASIC Commands and Keyboard Operations Unique to
83
C128Mode
Need help?
Do you have a question about the 128D and is the answer not in the manual?
Questions and answers