Sharp PC-1403 Operation Manual page 195

Hide thumbs Also See for PC-1403:
Table of Contents

Advertisement

189
6. Use TRON and
TROFF,
either
as
commands or
directly
within the program to trace
the
flow
of the
program through individual
lines.
Stop
to examine the
contents
of
critical variables
at crucial
points.
This
is a
very
sl
o w
way
to find a
problem,
but
sometimes
it
is
also the
only
way.
When entering a new
BASIC program,
it
is
usual
for
it
not
to work
the
first time.
Even if
you are
simply
keying in
a
program
that you know
is correct,
such
as
those provided in
this
manual, it is usual
to
make
at
least
one typing error. If it
is
a
new program of any
l
e ngth,
it will
probably contain
at least one logic
error as wel
l .
Followi
n g are some
general hints on
how to find and
correct
your
errors.
You run your program
and
get
an error
message:
1.
Go back
to the
PROgram mode
and
use
the
[D
or
the
[D
key to
recall the
line
with
the
error.
The
cursor will
be
positioned
at
the
place in the l
i ne
where
the
COMPUTER
got
confused.
2.
If you can't
find an obvious error
in
the way
in
which the
line
i
s
written,
the
problem
may lie with the
values which are
being
used.
For
example, CHR$(A)
will produce
a space if A
has a
value
of
1.
Check
the
value of each variable
in either the RUN
or
the PROgram mode
by typing
in the name
of
the variable
followed by
I
ENTER
I
.
You RUN the
program
and
don't
get an error
message,
but it doesn't do
what
you
expect.
3. Check through the
program line by
line
using LIST
and
the
[1]
and
[I]
keys to
see if you have entered the program
correctly.
it
is surprising how many errors can
be fixed by just taking
another look
at
the program.
4. Think about each line as
you
go
through
the
program as if
you
were the computer.
Take sample values and
try
to apply
the
operation in
each
line to see if you get the
result that you
expected.
5.
Insert one or more extra PRINT
statements
in
your
program to display key values
and key
locations.
Use
these to isolate
the
parts
of the program
that
are working
correctly and
the location
of
the
error.
This approach
is also
useful
for determining
which parts of a program
have been executed.
You
can
also use STOP to
temporarily
halt
execution
at
critical
points so that several
variables can be
examined.
BASIC De.bogging
'
Troubleshooting

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents