Commodore 2001-8 User Manual page 114

Table of Contents

Advertisement

Chapter 9.
ERRORS AND DIAGNOSTICS
One of the advantages of the highly interactive way in which you are able to use your PET is that errors
are easily correctable, due to the fact that the languages that are used within the machine have specific
rules under which the not so smart computer can operate. These rules are necessary to allow the
language to be able to understand what you are trying to tell it. Whenever BASIC cannot perform a
function, it will tell you about it in the form of an error message. A total list of the error messages and
some examples of what causes them follows.
The advantage of having this immediate response on the screen is that you can use the screen editor to
immediately fix the problem as it occurs. In most cases, the problem is going to be obvious to you. The
most common error is the syntax error problem, which means that you have typed the line to BASIC that it
doesn't understand. The correction for this type of problem is to list the line that is being complained
about and compare the typed data to what you thought you were going to type. About 90 percent of the
time, you will discover the mistake by superficial inspection. If not, you may have to make reference to
the appendix which defines the form for all the BASIC statements and if that does not clarify it for you, go
to the individual write-up to understand what you are doing wrong.
The common problems are you have got a comma in the wrong place, or you used a variable that cannot
be used in this particular kind of format. The basic premise to remember when correcting errors is that
although the language is forgiving of exact requirements for spaces verses no spaces etc., that the rules
are expliciLlf you violate the rules, the computer is going to continue to complain about an error until you
give it a problem it understands. Sometimes, the error is not as easy to undestand, although in almost
all cases while executing a problem, if an error is encountered, the line number will be indicated.
Sometimes a problem is the result of a programming mistake that you have made in a previous
computation. For instance, if you get a divide by zero in line 75and you know you shouldn't be dividing by
zero because, in your opinion, the value that is in the divisor should never be zero. The error is probably
not on tine 75, but somewhere further up your program where you define the variable. In order to attack
this kind of proble.m, the use of temporary print statements is the common technique. In other words, if
the variable is zero on line 75 and you don't think it should be, then you should I;st the portion that defines
the variable. More often than not, an inspection of this area will show the problem to you immediately. If
not, insert lines at appropriate places where the variable is computed to see when the variable acquires a
value that you don't expect. This technique will usually allow you to figure out the problem in your
programming.
The error messages in PET BASIC have been expanded over those other BASICs to give you a readily
English format for what the message is. However, other than using the techniques which we have just
described, the computer cannot fix a problem for you, it is in this area that programmers are made or
broken. Just remember
~hat
nobody is looking over your shoulder and use the machine to help you
understand the problem. If necessary, write little test routines which do only a piece of your program,
until you understand what is causing your problem.
ERROR MESSAGES
On encountering an error in interpretation of a statement, whether in direct or program
execution, BASIC displays a diagnostic message then returns to direct mode.
?MESSAGE ERROR IN LINE NUMBER
READY.
113

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents