4-3
Variables
We
can then use array variables such
as
A(O),
A(l),
A(2), A(3),
B(O),
B(l),
B(2), B(3).
For
a character array variable, add the
symbol$
after the variable name.
DIM
A$(4)
This declares the array elements A$(0), A$(1 ),
...
A$( 4)
as
the character
array variables.
2) Declaration
of
two-dimensional array variables
When declaring two-dimensional array variables with a
DIM
statement,
punctuate the subscripts with a comma.
DIM
A(2,3)
The array variable
is
now declared in two-dimensions. There are 12 array
elements
as
shown in the table below.
(
~
~
A(O,
0)
A(O,
1)
A(O, 2)
A(O,
3)
y
x
\
A(l,
0)
A(l,
1)
A(l,
2)
A(l,
3)
A(2,
0)
A(2,
1)
A(2,
2)
A(2,
3)
For a character array variable, add the
symbol$
after the variable name.
As
in
the case
of
one-dimensional array variables, multiple array variables can
be declared at the same time by punctuating with commas.
3) Declaration
of
three-dimensional array variables
Punctuate the subscripts with commas similar
to
when declaring two-dimen-
sional array variables.
DIM
A$(1,2,3)
Array declaration
is
in
three dimensions with character array variable A$.
There are 24 array elements (2 x 3 x 4) and since they exist independent
of
the character variable A$, the contents
of
the array variable remains un-
changed regardless
of
what
is
substituted for A$. Similar
to
the one-dimen-
sional array variable, it
is
possible
to
declare multiple array variables at the
same time by punctuating with commas.
59