10.02.2013 Views

a E i - Commodore Is Awesome

a E i - Commodore Is Awesome

a E i - Commodore Is Awesome

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Whether you are entering a program<br />

from a book or magazine or you are<br />

trying to create your own masterpiece<br />

those little bugs always manage to slip<br />

their way into your code somewhere.<br />

So what do you do? Well, the first<br />

and most obvious method of debugging<br />

a program is to sit down and<br />

read it through. Even this isn't infallible,<br />

and so I speak from experience,<br />

you check it, your neighbour checks it,<br />

Freddie the family parrot even gets in<br />

one the job. But still the error hides in<br />

their somewhere.<br />

Having dealt with people's<br />

programming queries for a number of<br />

years I have noticed a several specific<br />

programming errors keep rearing their<br />

heads again and again. I hope this<br />

article will provide some tips that will<br />

help you to de-hug your programs<br />

more easily.<br />

know it Ali?<br />

Some people think that the computer<br />

is a device that is totally infallible, this<br />

isn't the case. Probably the most<br />

common problem is the fact that the<br />

computer gives you an error in a<br />

certain line number. You go to the line,<br />

check it, check it again and even get<br />

someone else to check it. Don't be<br />

fooled, just because the computer says<br />

that the error is in line X, DON'T<br />

BELIEVE IT. Your problem may be<br />

elsewhere. I shall prove this point in an<br />

example later in this article.<br />

All Blank<br />

PROGRAMMING<br />

Fault Finding<br />

Quite often people will write or type in<br />

a program, RUN it and then find they<br />

simply get a blank screen. One of the<br />

most common mistakes here is that<br />

you may not realise that the computer<br />

may be giving you an error report, it's<br />

Entering a program into your computer only to .<br />

fi nd t h a t<br />

it doesn't work is extremely frustrating. Here are a few<br />

tips on some of the most common problems.<br />

By Stuart Cooke<br />

just that you can't see it. A small<br />

example will illustrate just what I<br />

mean. Type the following into your<br />

cornputer:<br />

10 POKE 53280,0:POKE 53281,0<br />

20 PRINT "[ BLACK] HELLO<br />

WORLD"<br />

Line 10 should be replaced with the<br />

following if using a CIO, Plus/4 or<br />

C128.<br />

10 COLOR 0,1:COLOR 4,1<br />

Don't forget items in square brackets<br />

are mnemonics for <strong>Commodore</strong><br />

control codes. Read Listings if you are<br />

not sure about this. [BLACK] means<br />

press the CONTROL &I keys at the<br />

same time,<br />

RUN this program and see what<br />

happens. The program works OK, you<br />

simply can't see the message that is<br />

printed since it is printed on a black<br />

background with black text. Line 10<br />

simply sets the border and screen to<br />

black.<br />

Now this program works without<br />

any problems, but what would happen<br />

If there was an error in there? Let's add<br />

a line to the above example:<br />

30 THIS WILL CREATE AN<br />

ERROR<br />

As you are no doubt aware this line<br />

will cause a SYNTAX ERROR when<br />

the program is RUN. Let's RUN it and<br />

see. What happened? Nothing seemed<br />

to happen, your screen is still black.<br />

The error message will be printed out,<br />

you simply can't see it as it is in black<br />

on a black background. If we change<br />

the colour of the text in line 20 then all<br />

should become apparent. Change line<br />

20 to:<br />

20 PRINT "[WHITE] HELLO<br />

WORLD"<br />

YOUR COMMODORE january 1987<br />

109<br />

Remember what I said about square<br />

brackets.<br />

Now RUN the program and you<br />

will see the SYNTAX error message<br />

appear.<br />

You mayu think that this is an<br />

extremely simple error and that everyone<br />

should spot it. It may be simple but<br />

is overlooked surprisingly often.<br />

Cl28 owners have a further<br />

problem. the FAST command. For<br />

those of you not used to this command<br />

it simply turns off the display of the<br />

C128 which means that the computers<br />

speed will increase. You can still print<br />

to the screen, but you can't see what<br />

you put on it. So what would happen if<br />

the computer came across an error?<br />

You would get the same effect as<br />

above. The error message will be<br />

printed to the screen you just won't be<br />

able to see it. As a general rule of<br />

thumb, when entering a C128 program<br />

omit all FAST statements until you are<br />

sure that the program is working<br />

correctly. Then put the FAST<br />

statement back in,<br />

If you own a Cl28 then you could<br />

try the following program to demonstrate<br />

this:<br />

10 FAST<br />

20 PRINT "HI THERE !"<br />

30 I'M GOING TO CAUSE AN<br />

ERROR<br />

Now RUN the program. The program<br />

will print out the message in line 20 and<br />

line 30 will generate an error message,<br />

you simply can't see it.<br />

Enter the following command on<br />

the keyboard. You won't be able to see<br />

it so type carefully:<br />

SLOW<br />

Your screen will now come back on<br />

and you will see both the 'HI THERE!'<br />

and the error message.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!