(Example 1)
1 0 0 I M A C 5
)-
· · · · · · · · · · · · · · · · · · · · · · · Declares !-dimensional numeric array A with 6 elements.
2 0 0 I M X $ (8 )- ............
..
....
..
Declares !-dimensional string array X$ with 9 elements.
1 0 0 I M
AC
5 ), X $ (8 )
··
··
····· Performs the same function
as
lines 10 and 20 above.
(Example 2)
·
1
0 0 I M 8 C 5 . 5 ) · · · · · · · · · · · · · · · · · · Declares 2-dimensional numeric array B with 6 x 6
elements.
2 0 0 I M Y $ C 5 . 8 ) · · ·
..
· ·
..
· · · · · · Declares 2-dimensional string array Y$ with 6 x 9 elements.
1 0 0 I M 8 C
5.
5
),
Y$
(
5,
8 ),
AC
5
),
X $ ( 8 ) ........
.. ..
Declares two numeric arrays
and two string arrays.
(Example 3)
1 0 0 I M C ( 3 , 3 ,
3)
· · · · · · · · · · · · Declares 3-dimensional array C with 4 x 4 x 4 elements.
Note:
Different names must be used for each array which is declared; for example, the instruction DIM
A(S), A(6) is
not
a legal array declaration.
Try
executing the program shown below and check the results which are obtained.
1 0 0 I M
AC
2 ) .
8$
(2 )
2 0 A
C0)
=26
30
A C1 )= 9
4 0
AC
2 )
=-1
00
5 0
8$
(0)
= "
A8C
"
6 0
8$
( 1 )= "
XY
Z "
70
8$
(2 )= "
MZ-
700"
8 0
PRINT
A C1 )
9 0
PRINT
8$
(2 )
1
00
PRINT
A C2 )
1 1 0
PR
I
NT
8$
(0)
+8$
(1 )
1 2 0
PR
I N T A
(0)
Note: Individual variables within an array, such as A(S) and X$(8), are referred to
as
an array's elements.
Numeric constants, numeric variables, and numeric arrays are collectively referred to
as
numeric
expressions, and string constants, string variables, and string arrays are collectively referred
to
as
string expressions.
------
--------------------------
------------
--
--------
------
----
--
------2
5