Radio Shack TRS-80 User Manual page 88

Micro computer system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

THE PROGRAM.
This
may
seem
startling,
but
do
the following
and
you
will
see:
1.
Move
the
DATA
line
from
line
10
to
line
25
and
run.
No
change
in
the printout,
right?
2.
Move
the
DATA
line
from
line
25
to
line
10000.
Same
thing
no
change
in
the
printout.
Data
line(s)
can
be
placed
anywhere
in
the
program.
This
fact leads different
programmers
to use
different
styles.
Some
place
all
DATA
lines at
the beginning of a
program
so
they can be
read
first
in
a
LIST and
found
quickly
so
data
may
be changed.
Others
place
all
DATA
lines at
a
program's
end where
they
are
out
of the
way
and
there are
more
line
numbers
available
to
keep
adding
DATA
lines as
the
need
arises.
Still
others
scatter
the
DATA
lines
throughout
the
program next
to
the
READ
lines
which
bring that
data
into
use.
The
style
you
use
is
of
little
consequence
but
consistency
is
comfortable.
The
Plot
Thickens
Since
you
now know
all
about
FOR-NEXT
loops,
let
us
see
what
happens
when
a
DATA
line
is
placed
in
the
middle of
a loop. Erase the old
program
with
NEW
and
type
in
this
program
:
10
DATA
1,2,3,4,5
20
FDR
N
=
1
TO
5
30
READ
A
40
PRINT
As
50
NEXT
N
.
.
.
then
RUN
.
That
DATA
line
started outside the loop.
Now
move
it
to
line
25 and
RUN.
What
hap-
pened?
Nothing
different!
It
is
important
to
note
this
fact
or
we
wouldn't have gone
to the trouble
to
do
it.
Note
that
as
we
went
through
the
N
loop 5
times,
we
read the
letter
A,
and
the
PRINT
statement only printed A, but
A's value
was
different
each
time.
Its
value
was
the
same
as
the value
it
last
READ
in
the
DATA
line.
The
reason
each
piece of
data
in
a
DATA
line
can only
be
read
once each
time the
program
is
run.
The
next time
a
READ
statement
requests a piece
of
data,
it
will
read the
next
piece
of data
in
the
DATA
line,
or,
if
that
line
is
all
used up, go
on
to
the
next
DATA
line
and
start
reading
it,
86

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents