EasyManua.ls Logo

Radio Shack TRS-80

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...
Now,
we
could give
each
of these
cars a
different
letter
name,
using
the
variables A
through
J,
but what a
waste
and what
will
we do
when we have a
thousand
cars, not
just ten?
Your TRS-80
LEVEL I
Interpreter
provides
for a
single
array, and it
is called
"A". This
is
not
the same as
the
alphabet
variable
"A",
and
it is not the
same
as
the "A"
used
in
the
string
variable A$.
It is a
third and
totally
separate
"A".
You
will
recognize
it as
A-sub(something).
We
will name the
cars A(l)
through A(10),
pronounced
A sub
1
through
A sub 10.
Get
the idea?
Next,
let's
store the
car engine
sizes in a line
or
two of
DATA
statements.
Type
in
:
100
DATA
300.200,500,300,200
110
DATA
300,400,400,300,500
Notice
how
careful
we are
to
keep
the DATA
elements
in order,
from
1
to
10,
so the
first
car's
engine
is
found
in the
first DATA
Location
and the
10th
one's
in the last
location.
Now we
have to
"spin up"
an array
inside
the
Computer's
memory
to make
these data
elements
immediately
addressable.
Think how
difficult it
would be to try
to
address the 7th
engine
(or
the 7
thousandth!)
for
example,
using
only
what
we've
learned so far. It
can
be
done
using
only
DATA,
READ
and
RESTORE
statements
but
it's very messy and
slow.
The easy way
to
create
the array
is
as
follows . . .
Type
in:
50
FDR
L
=
1
TO 10
55 READ
A(L)
60
NEXT L
.
.
.
and RUN.
Nothing happen?
Yes, it
did.
RUNagain
and note
that
something
happened
because it took
a
little
time
for
READY
to
return.
We
simply
didn't
display
what
did
happen.
What's
that
-
you're
n&f
sure you
believe
that
there
can
be
three sepamteond
different
storage
places
for
these
"A"
item?
0K,tryit-type:
'
'<
£.*.
£i
i
y'ow
-name;)
;
;
then
type:
PRINT
A,
A$, A{ 1
)
» i .
NOW
what
do you
think?
Did that
make
you
"
a
believer??
;
'
'^\-0'.
:
:^
?
^-^
:
:-
:[}
--
^
Big
words
meaning
"so
we
can
find a car fast!"
124

Other manuals for Radio Shack TRS-80

Related product manuals