29.12.2012 Views

spectrum utility - OpenLibra

spectrum utility - OpenLibra

spectrum utility - OpenLibra

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Getting a program typed in is often only the<br />

start of your problems. Ed to the rescue.<br />

Typing in a program is a useful<br />

exercise. Apart from the patience<br />

required, techniques<br />

learned and the end program to<br />

be used, probably the most<br />

educational part of it is tracking<br />

down the bugs introduced by<br />

yourself or occasionally by our<br />

publication system.<br />

In debugging you gain a<br />

much deeper insight and<br />

understanding on how the program<br />

actually works than by<br />

merely typing it in, but tracking<br />

down these errors is an art in<br />

itself and needs some skill. So<br />

here are some tips to help you in<br />

your efforts when faced with<br />

that cryptic error report!<br />

1 NEXT without FOR<br />

Look back through the program,<br />

either the loop has not been set<br />

up — no related FOR 'letter' =<br />

No1 TO No2 line, or the letter<br />

has been re-used as an ordinary<br />

variable within the loop with a<br />

LET 'letter' = No.<br />

2 Variable not found<br />

This is one of the most common<br />

errors. Again, the problem may<br />

not lie in the line where the error<br />

was detected and reported. If<br />

there is only one variable, which<br />

may be one or more letters or a<br />

string 10 THEN LET X= 10<br />

4 Out of memory<br />

As well as for programs which<br />

are too big, it may happen if the<br />

previous program set RAMtop,<br />

Before despairing, enter CLEAR<br />

USR"a"-1 on the Spectrum: on<br />

the ZX81 SAVE the program,<br />

turn the machine off and on,<br />

then reload the program.<br />

7 RETURN without GOSUB<br />

Somehow the computer has<br />

reached a RETURN command<br />

other than via a GOSUB instruction,<br />

Check a GOTO hasn't been<br />

entered in place of a GOSUB.<br />

Check for a missing GOSUB.<br />

B Integer out of range<br />

An integer {whole number)<br />

either as a number of variable is<br />

too big or small and you are attempting<br />

to do something like<br />

PRINT AT 0,33 not allowed!<br />

Check any variables involved as<br />

per report 2 and trace it back<br />

through the program looking for<br />

adjustments to it by + - * / :<br />

Add limiting code if needed —<br />

see report 3<br />

E Out of DATA<br />

A Spectrum problem. Check the<br />

number of DATA items match<br />

the number of READs; usually<br />

one (or more) has been missed<br />

out. Attempting to reread a<br />

DATA list without first using a<br />

RESTORE command will cause<br />

this and it can happen on an auto<br />

start program (saved with a LINE<br />

number). Good programming<br />

usually RESTORES to the correct<br />

line number before using<br />

READ.<br />

I FOR without NEXT<br />

See report 1 but this time the<br />

NEXT is missing!<br />

Note that the letters I have used<br />

for examples could by ANY letters<br />

not just A$,X,Y etc and depend<br />

on the particular choice of<br />

the programmer.<br />

This is by no means a comprehensive<br />

list but I have tried to<br />

cover many of the most common<br />

error reports. Personally, I<br />

get almost as much satisfaction<br />

from debugging as I do from programming<br />

I do assure you,<br />

however, that there is absolutely<br />

no truth in the rumour that we<br />

deliberately inject bugs into our<br />

listings in order to introduce you<br />

to the dubious delights of<br />

debugging!<br />

123<br />

'

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

Saved successfully!

Ooh no, something went wrong!