2.3. 7 Definition statements
2. 3. 7. 1
DIM
Format
Function
Example
DIM a
1
(i
1
)
<,
a
2
(i
2
),
....................
ai (im) >
DIMb
1
(i
1
,jd<,b
2
(i
2
,j2),
..
. .
...........
..
bi(in,jn)>
ai
..
..
......
.
.....
!-dimensional array name (list)
bi
.....
...
........
2-dimensional array name (table)
im, in,
jn
. . . . . . . . . . . Dimensions
This statement is used
to
declare (define) arrays
with
from one to
four
dimensions
and to reserve space
in
memory for
the
number
of
dimensions declared (DIM :
dimension).
Up
to
two characters can be specified
as
the array name, and subscripts
of
any value
may
be
specified
to
define
the
size
of
dimensions; however,
the
number
of
dimensions which can be used
is
limited
in
practice
by
the
amount
of
free ·
memory available.
(Examples:)
1 0
DIM
A C
10
0)
2 0
FOR
0=0
TO
1
00
3 0
RE
A D
A
(0 )
4 0
NE
X T 0
5 0
DATA
5.
3 0 .
1 2
....
.
..
(Examples:)
1 0 D I M
A$
C1 ) .
8$
( 1 ) ,
C$
( 1 )
20
FOR
0=
0
TO
1
READ
A$
(0 ) .
8$
(
0)
30
C$
(0)
=
A$
( 0 ) +
11
11
+8$
( 0 )
40
PR
IN
T
A$
(0)
.
8$
(0)
.
C$
(0)
5 0
NE
X T 0
6 0
END
70
DATA
YOUNG.
GI
RL
.
WHITE.
ROSE
Note Execution
of
the
DIM statement sets the values
of
all elements
of
declared arrays
to
0 (for numeric arrays)
or
null (for string arrays). Therefore, this statement should
be
executed before values are assigned
to
arrays.
2. 3. 7. 2
DEF
FN
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.
All array declarations are nullified
by
execution
of
a CLR statement (see page
59)
and a
NEW
statement (see page
32)
.
I Format I
DEF
FN
f (x) = e
Function
f
..
. Name assigned to the function being defined (one uppercase
letter
from A
to
Z)
x
...
Argument (variable name)
e
..
. Numeric expression (constant, variable, array element,
or
function)
or
pre-
viously defmed user function
The
DEF
FN
statement
is
used
to
define user function
FN
f (x). Such functions
consist
of
combinations
of
functions which are intrinsic
to
BASIC.
55
----------------
--
--------------------------
------------------
----
------