ProvideX V8.20 > Language Reference > 2. Directives
85
DIM Directive
            Define Arrays and Strings
Formats
1. Define Array: DIM array_name[$](subscript_1[,subscript_2[,subscript_3]])
2. Drop Array: DIM array_name$
3. Define Composite String: DIM var$:IOL=iolref
4. Initialize String: DIM var$(len[,char$])[,...]
Where:
array_name[$] Numeric or string variable to be dimensioned as an array.
Value whose 1st character will be used to fill the variable up to the
char$
length specified. String expression.
iolref
Either a string variable containing the object code of an IOList or a
statement reference to an IOList (statement number or label).
len
Desired length of the string variable. Numeric expression, integer.
1st dimensions (min:max) of array. Numeric expression, integers.
subscript_1
2nd dimensions (min:max) of array. Numeric expression, integers.
subscript_2
3rd dimensions (min:max) of array. Numeric expression, integers.
subscript_3
var$
Name of string variable to be defined or initialized.
Description
Use the DIM directive to define an array, to define a composite string or to initialize a
string. Refer to the DIM( ) Function, p.413, to read the total number, minimum number
and maximum number of elements in an array. See also System Limits, p.830.
Note: For numeric arrays you can use either parenthesis ( ) or square brackets [ ]
to define arrays or reference elements. For string arrays, use square brackets [ ] to
avoid confusion with substrings. All arrays have three subscripts. An array defined as
X$[4] has values 0:4 for subscript 1, 0:0 for subscript 2, and 0:0 for subscript 3.
However, specifying the unused subscripts is unnecessary.
Format 1: Define Array
DIM array_name[$](subscript_1[,subscript_2[,subscript_3]])
Use the DIM directive to define an array with one, two or three dimensions. Specify the
dimensions using the values in the DIM statement. The dimensions of the array are
defined as [minimum]:maximum. If you omit the minimum dimension, then ProvideX
uses the default minimum, 0 zero. When you refer to items in arrays, the lowest subscript
is the minimum value specified, the highest is the maximum value specified. You can
redefine existing arrays using the DIM statement. The values of all elements in the array
are automatically initialized to zero or null by the DIM statement.
The following example defines a three-dimensional array with three elements (0
through 2) in each dimension for a total of 27 elements:
DIM A(2,2,2)