78
The
VIC
20
User
Guide
GL$(O,O)
= MP$(O) GL$(I,O) =
FV$(O)
GL$(2,O) = DP$(O)
GL$(O,I)
=
MP$(l)
GL$(I,I)
= FV$(I) GL$(2,1) =
DP$(I)
GL$(O,2) = MP$(2) GL$(l,2) = FV$(2) GL$(2,2) = DP$(2)
GL$(O,3)
= MP$(3) GL$(1,3) = FV$(3)
GL$(O,4)
= MP$(4)
GL$(O,5)
= MP$(5)
Arrays can represent integer variables, floating point variables,
or
string variables. However, a single array variable can only represent one
data type. In other words, a single variable cannot mix integer and floating
point numbers. One
or
the other can be present, but not both.
Arrays are a useful shorthand means of describing a large number of
related variables. Consider, for example, a table containing ten rows
of
numbers, with twenty numbers in each row. There are
200
numbers in the
table. How would you like it if you had to assign a unique name to each of
the
200
numbers? It would be far simpler to give the entire table one name
and identify individual numbers within the table by their table location.
That
is
precisely what an array does.
Arrays can have one
or
more dimensions. An array with a single
dimension
is
equivalent to a table with just one row
of
numbers. The
dimension identifies a number within the single row. An array with two
dimensions yields an ordinary table with rows and columns: One dimension
identifies the row, the other dimension identifies the column. An array with
three dimensions yields a "cube" of numbers, or perhaps a stack
of
tables.
Four
or
more dimensions yield an array that
is
hard to visualize, but
mathematically no more complex than a smaller-dimensioned array.
Let
us
examine arrays in detail.
A single-dimension array element has the following form:
name(i)
where
name
is
the variable name for the array. Any type
of
variable name may be used
is
the array index to that element. i must
start
at
O.
A single-dimension array called
A,
having
five
elements, can be visual-
ized as follows: