EasyManua.ls Logo

Radio Shack TRS-80 - Page 76

Radio Shack TRS-80
236 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
We
can insert
temporary print
lines
anywhere in
any
program so we follow
every
step
in
its
execution.
The Computer
can actually
overwhelm us with data, but by carefully indicat-
ing what we
want to
know, we can observe
the inner details
of
the calculations. Start
by
adding this line:
92 PRINT
"
#92
M
=
"
;M
...
and RUN
The essentials of
this
"test" or "debugging" or "flag" line are:
1.
It PRINTs something.
2.
The print tells the line number, for
analysis and
easy
location
for later
erasure,
3. It tells the name
of
the variable you are watching at that
point
in the
program,
4.
It gives the value
of
that variable at that point.
It is
most helpful
of
all when inserted in FOR-NEXT loops
so
:
97 PRINT
'*
#97
A
=
"
;A
...and
RUN.
Wow! The data
really comes thick and fast! Hard to keep
track of so
much information, and
we've barely
begun.
This tells what is happening during each pass
of the loop.
Is there
some
way to make it more
readable? Sure.
Can
you think of a way?
Yes, there
are
lots of
ways. Indenting is just one
simple
way to keep
the
answers
separated
from
the trouble shooting
data. Retype lines 92 and 97 as follows:
"
#92 M
=
"
}M
"
#97 A
=
"
;A
92 PRINT
"
97
PRINT
"
... and RUN.
Ahhh. How sweet it is. That is
so
easy to read, let's monitor some
more
points
in the
pro-
gram.
Type in:
125 PRINT
"
"
,"
"
,"
#125
M
=
"
;
M
135 PRINT
*'
"
,"
"
,
"
#135 M
=
"
;
M
...
and RUN.
74
.
This '^agglftg"
is
:
such a wonderful
troubleshootr
:
ing
tool
in stubborn programs that you
will warit
to make
a habit of n«ver forgetting to
use it when
-
thegoing
gsts tough.

Other manuals for Radio Shack TRS-80

Related product manuals