Radio Shack TRS-80 User Manual page 127

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

Advertisement

We
obviously used a
FOR-NEXT
loop
to
READ
10
DATA
elements,
and
named
those
elements
(or "cells")
in
which
they're stored,
A(l) through A(10).
Let's see
if
we
can
PRINT
out
the values
in
those array elements.
Type:
200 FOR
N
=
1
TO
10
210
PRINT
A(N)
220 NEXT
N
.
.
.
and
RUN.
Aha!
It
works, but
how?
We
read the
DATA
elements
into
an
array called
A(L),
but
printed
them
out of an
array called
A(N).
What
gives?
Oh,
nothing,
really.
The
array's
name
is
"A".
The
location of
each data element within that array
is
identified
by
the
number which
we
place
inside
the parentheses.
We
can
bring that
number
to inside
the parentheses
by
using
any
of our 26
letter
variables,
and
can even
do
some
simple
arithmetic
inside
those paren-
theses
if
we
wish.
Remember,
though, there
is
only
one
array,
and
its
name
is
"A".
Its
elements
are
numbered,
and
called
A-sub (number).
Let's
work some more
on
the
program.
Type:
170
PRINT
180
PRINT
"LICENSE #", "ENGINE SIZE"
210
PRINT N,A(N)
.
.
.
and
RUN
.
Now
that's
more
like
it.
We
have every
license
number,
every engine
size,
and
are
not
"using
up"
any
of the
26
alphabetic
variables.
Having demonstrated
that point, erase
lines 20(5,
210
and
220,
and
type:
10
IN.
"WHICH
CAR
'
S
ENGINE SIZE DO YOU WANT
TO
KNOW";W
2
10
PRINT W.A(W)
...
and
RUN.
Some
pure mathematicians
might
insist
on
catling
A{X)
-
A
"OF"
X.
Who
needs
that
added
conftision?
Best
'teat
you know,
just in
'
*s$&
;
:
M
125

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents