
7-6
Section
Details of BASIC Commands
151
dim
Syntax:
DIM
<variable> ( <array index> {, <array index>} ) {,<variable> ( <array index> {, <array
index>} )}
Description:
Statement. Specifies the order of the array and the maximum value for the array variable
subscripts. Allocates the necessary memory for the array.
The <variable> is any valid variable name. When array variables are declared, the constant array
variables are initialized to 0 and character string array variables are initialized to NULL. An array
may have up to 255 subscripts (dimensions), but an array cannot be declared that is larger than the
available memory in the ASCII Unit.
The <array index> is any valid integer in the range: [0…65535]. A constant must be used when
the static method is used for character variable area allocation.
The default value for the <array index> is 10 when an array variable is used without the DIM
statement (without declaring the array).
Note: The DIM command must be executed before any substitute expression.
Remarks:
Note:
1.
An array variable allows multiple elements of data to be specified with a single
variable name. The data element is specified by the number in parentheses after the
variable name (constant or string type). This element number is called the subscript.
An array with one subscript is one-dimensional, an array with two subscripts is two
dimensional, and so on.
2.
The statement DIM A$(3) declares a one-dimensional array of string variables with
variable name A$. The following four variables can be used: A$(0), A$(1), A$(2),
and A$(3).
3.
The statement DIM B(3,2) declares a two-dimensional array of constant variables
with variable name B. The following twelve variables can be used: B(0,0), B(1,0),
B(2,0), B(3,0), B(0,1), B(1,1), B(2,1), B(3,1), B(0,2), B(1,2), B(2,2), and B(3,2).
4.
Array subscripts begin from 0 as shown in the examples above. If arrays are to be
started with subscript 1, use the OPTION BASE statement.
Examples:
>
10 DIM A(5)
>
20 FOR I = 0 TO 5
>
30 A(I) = I
>
40 PRINT A(I)
>
50 NEXT I
>
RUN
0
1
2
3
4
5
See also:
OPTION BASE
Содержание C200H-ASC11
Страница 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Страница 2: ...iv...
Страница 4: ...vi...