Classic Computer Magazine Archive COMPUTE! ISSUE 39 / AUGUST 1983 / PAGE 188

Troubleshooting A Program

John Blackford, Assistant Features Editor

Suppose you've typed a program into your computer from the pages of COMPUTE!, and it doesn't run. The following checklist should help you find the problem in a jiffy.

There are two likely sources of trouble in a typed program: typing errors made as you enter the program into your computer or mistakes involving COMPUTE!'s conventions – the symbols used to indicate special keystroke combinations. If you have successfully typed in programs from the magazine before, the problem is probably a typing error. But if this is your first try (or if you are working with a new computer which is unfamiliar to you), you may be having trouble with the listing conventions.

Knowing How To Enter The Program

First take a look at the articles published each month, "How To Type COMPUTE!'s Programs," and "A Beginner's Guide To Typing In Programs." As you'll see, finding a character or word enclosed in braces is either a function key – such as the "CLEAR" key – or a normal key pressed simultaneously with a control or escape key. Don't type in either the letters of the word in braces, or the braces themselves. Instead, press the key or keys indicated by the words within braces. {CLEAR} means, press the CLR key.

What about the possibility that the program in the magazine is incorrect? Each program we publish is tested carefully, and the versions for each different computer brand are checked separately. When we have a given version running smoothly, we LIST the program directly onto paper. This paper version is photocopied and then appears as is in the magazine. Because of this, there is very little chance of a typographical error in the magazine version – it is identical to the program that was pretested in the computer.

Still, we have made mistakes. In almost every case, though, a program will run correctly as printed. If you continue to have problems after having followed these troubleshooting procedures, check the section of the magazine called CAPUTE! the next issue or two following the program in question.

On the other hand, there is a good chance that a typing error crept in as you keyed the program listing into your computer. The result can be anything from a slightly quirky display (such as square trees) to no game at all – just a cryptic error message or even a lock-up. When a computer locks up, the keyboard and RESET keys have no effect. To regain control, you must turn off the computer. Everything you typed in is lost. To avoid this disaster, always SAVE your program before you try to RUN it.

Finding The Source Of A Problem

Often, you can trace a mistake by knowing how to interpret error messages. Some computers give you a statement such as "OUT OF DATA," while others give only an error number. If you get a number, look it up in your user's manual. The error statement or number is accompanied by a line number, which helps in locating the problem.

First, LIST the line and make sure that it is exactly the same as the one in the magazine. If it isn't, make the required changes and try to RUN the program again.

Sometimes, the actual error is not on the line named as the source of the problem. If a DATA entry is missing, the error is listed at the line containing the READ instructions. If a string is incorrectly DIMensioned, the error will occur in the line that first calls for the variable, not in the line containing the DIM statement.

Likewise, if you forget to use RETURN to end a subroutine or tell the program to jump to a nonexistent line, the error message will refer to where the computer failed to carry out your instructions, not to where the mistake actually is located. Thus, interpreting this kind of error message requires some imagination, but at least the messages narrow your search to two areas.

If you go through the above steps and still don't find a mistake, you'll have to check the program line by line to be certain that each character is exactly the same as the original text. First, check the line numbers themselves, comparing number by number. Make sure none are missing and that there are no extra ones which never appeared in the magazine.

Now, check the program line by line. As you go, recheck the line numbers. A common mistake is to enter correct information on the wrong line, and it is very easy to miss this when checking because your eye tends to jump from what you read on the screen to the same thing on the page. You may not notice when a program line is matched up with the wrong line number.

Look For Omissions

Another common problem is skipping part of a line or repeating part. A small omission of this sort can produce dramatic results. In the following example, leaving out part of the line creates an "endless loop" that will stop the program in its tracks:

10 X = 0
20 X = X + l
30 PRINT X
40 GOTO 20

This program will never get beyond line 40. Line 20 should have read:

20 X = X + 1 : IF X > 10 THEN GOTO 50

The second part of line 20 allows the program to get out of the loop. Keep on the lookout for such omissions when you compare the listing line by line.

Once you have cleared up the major problems that keep the program from running at all, you can fine tune any glitches in the display. These can be tedious, but at least you have something to work with and can see right on the screen how your changes are affecting the program.

Troubleshooting can be frustrating. But when you check things out step by step – starting with the most likely sources of trouble – you will reduce your "debugging" time dramatically.