13
3.5 Locating the Error
Something has happened to prevent the
program executing successfully. To discover
where the error occurred type:
HELP (RETURN)
The screen will appear as shown in Figure 3-2.
Figure 3-2. The First Error Highlighted
You will notice that the quote mark is
highlighted in reverse-field in line 650/ . This
indicates the approximate position of the error.
You will no doubt have noticed that “THE”
should have been the BASIC code THEN.
Correct this error and run the program again.
Now another problem is obvious. The player
appears to be out of money when he shouldn’t
be. To discover how much money he does have,
press the STOP key after the BROKE message
has flashed a few times, and type:
DUMP (RETURN)
The screen will appear as shown in Figure 3-3.
Figure 3-3. Dump of Variables
The program is obviously not functioning
correctly. You can see what has gone wrong by
using the STEP command (see Section 2.4.12) to
execute the program instruction by instruction.
Because the BASIC code INPUT has been used
in this program near the top of the screen, you
must change line 550/ to read as follows:
550/ [F8]” (SHIFT/CLR HOME/CRSR DOWN/
CRSR DOWN/CRSR DOWN/CRSR
DOWN/CRSR DOWN/CRSR DOWN/
CRSR DOWN/CRSR DOWN)”:[F7]
“WHAT IS YOUR BET”;B
The program is still not running correctly
because the user runs out of money even when
betting within his limits. To discover the reason
why this is happening, type the following:
STEP (RETURN)
RUN (RETURN)
When you reach the instruction which displays
whether VIC wins or you win, check the number
of the line that appears at the bottom of the
window. During the first pass through the
program, providing the bet did not exceed 40/
pounds, the next line should be the point at
which the game restarts, i.e. line 250/ . In fact, line
10/ 50/ is displayed in the window. The fault lies in
line 90/ 0/ . It reads GOTO 10/ 50/ when it should
read GOTO 250/. Change the code and the
program should execute normally.
The STEP and TRACE commands slow down
program execution (see Sections 2.4.12 and
2.4.13), so if you use either of these commands
initially, type OFF (see Section 2.4.14) to enable
the program to run at the correct speed. The
command KILL will cancel PROGRAMMER’S
AID enabling you to run the program at normal
speed. (See Section 2.4.17.)