Sharp MZ-700 Series Owner's Manual page 58

Personal computer
Hide thumbs Also See for MZ-700 Series:
Table of Contents

Advertisement

2.3.7 Definition statements
2. 3. 7. 1 DIM
Format
Function
| Example
Note
2. 3. 7. 2 DEF FN
Format
Function
DIM a j ( i j ) < , a
2
(i
2
),
ai (im) >
D I M b j ( i i , j i ) < , b
2
(i
2
, j
2
),
bi (in J n ) >
ai
1-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
D I M
A ( 1 0 0 )
2 0
F O R
J = 0
T O
1 0 0
3 0
R E A D
A CJ)
4 0
N E X T
J
5 0
D A T A
5 , 3 0 ,
1 2 ,
(Examples:)
1 0
D I M
A $ ( 1 ) , B $ ( 1 ) , O S ( 1 )
2 0
F O R
J = 0
T O
1
:
R E A D
A S ( J ) , B $ CJ)
3 0
O S CJ) = A $ CJ) + "
" + B S
CJ)
4 0
P R I N T
A S CJ) , B $ CJ) , O S CJ)
5 0
N E X T
J
6 0
E N D
7 0
D A T A
Y O U N G , G I R L , WH I T E ,
R O S E
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.
Different names must be used for each array which is declared; for example, the
instruction DIM A(5), 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).
DEF FN f (x) = e
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 defined 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.
56

Advertisement

Table of Contents
loading

Table of Contents