EasyManua.ls Logo

Radio Shack TRS-80 - Page 89

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...
Change line
20
in the program to read:
20 FOR N
=
1
TO 6
. . . and RUN
.
We, of
course, told the
READ
statement to read a total of 6 pieces of DATA but there were
only 5. An
error
statement
caught
us, as
the screen shows,
12 3
4 5 HOW?
30 READ A?
Now change
line
2(3
so the
number
of
READs is
less
than the DATA
available
20 FOR N
=
1 TO
4
. . . and
RUN.
The
program ran just fine as long as
we
didn't use all the available data.
The
point
is, each
piece
of
data
in
a
DATA statement can
only be
read once during each RUN.
Exceptions,
Exceptions!
Because it is
sometimes necessary to
read
the same DATA more than once
without
having
to RUN
the complete program
over,
a
statement called RESTORE is
available.
Whenever the
program comes across a RESTORE,
all DATA
lines are restored to
their original "unread"
condition, both
those that
have been read and
those that
have not, and
all
are
available for
reading again,
starting
with the first piece
in the first DATA line.
Change
line
20
of the pro-
gram
back to
20
FOR
N
=
1
TO
5
and insert
35 RESTORE
and
RUN.
Oh-oh! The screen prints five l's instead
of
1 2 3 4
5.
Can you figure out why?
"ONE
MORE
TIMET'
87

Other manuals for Radio Shack TRS-80

Related product manuals