EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 183

Radio Shack TRS-80 Model III
274 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...
BASIC
20 /
Arrays
An
array is simply
an
ordered list
of
values . In
Model III BASIC these values may
be
either numbers
or strings,
depending
on
how
the
array is
defined
or typed. Arrays
provide a
fast
and organized
way
of
handling large
amounts
of
data
.
To illustrate
the power
of
arrays, this
chapter traces the
development
of
an array
to
store
checkbook data
: check numbers ,
dates
written
,
and amounts
for
each check
.
In addition,
several matrix
manipulation
subroutines are listed at
the
end
of
this
chapter. These
sequences will
let you add,
multiply, transpose,
and
perform
other
operations on arrays.
Note:
Throughout this
chapter,
zero-subscripted
elements are
generally ignored
for
the
sake
of
simplicity
.
But you
should remember
they are available and should
be used
for
the most
efficient
use
of
memory. For example,
after
DIMM4), array
A
contains 5 elements: A(0),
A(l), A(2), A(3), A<4).
For background information on
arrays,
see
Chapter
18,
DIM, and Chapter
15
"Arrays"
.
A Check-Book Array
Consider the following table of checkbook
information:
Check
#
Date
Written Amount
025
1-1-78
10.00
026
1-5-78
39.95
027
1-7-78
23.50
028
1-7-78
149.50
029
1-10-78
4.90
030
1-15-78
12.49
Note that every item in the table may be specified
simply by reference to two
numbers: the row number and the column
number. For example, (row
3,
column
3)
refers
to the amount 23.50. Thus the number pair
(3,3)
may
be called the
"subscript
address" of the
value
23.50.
Let's set
up
an array, CK , to correspond
to the checkbook information table. Since
the table contains 6 rows and 3 columns, array CK
will need two dimensions: one
for
row numbers, and one for column numbers. We can
picture the
array like this:
A(l,l)
=
025
A(l,2)
=
1.0178 A(1.3)=
10.00
A(6,l)
=
030
A(6,2)=
1.1578
A(6,3)=
12.49
173

Other manuals for Radio Shack TRS-80 Model III

Related product manuals