DIM Verb

Syntax

DIM dimitem{,dimitem...}{,ERR=lineref}

Description

For BBj-specific information, see the DIM Verb - BBj.

The DIM verb is used to allocate and reallocate arrays as well as create simple strings and string templates.

Parameter

Description

dimitem

Dimension item; can be one of four formats:

strname(int{,string})

Creates a simple string. The integer can be any value from 0 to memory size and specifies the length of the string. If the optional string argument is given, the first character is used to initialize the dimensioned string. If no string argument is given, the string is initialized to all spaces.

The DIM verb serves as a shortcut for setting up a string. The statement DIM A$(5,"*") and LET A$="*****" have the same end result. The DIM verb is unnecessary for creating simple string variables and does not establish a fixed length of a simple string variable.

numname[dimensions]

Allocates a numeric array. The DIM verb is necessary to create an array before any attempt to access it. When defining an array, up to three subscript ranges may be given. If the lower end of the range is not given, it is assumed to be zero. Any attempt to access a subscript outside of the dimensioned range results in an error. Every element of a numeric array is initialized to zero by the DIM verb.

strname[dimensions]{ (int{,string}) }

Allocates a string array. The DIM verb is necessary to create an array before any attempt to access it. When defining an array, up to three subscript ranges may be given. If the lower end of the range is not given, it is assumed to be zero. Any attempt to access a subscript outside of the dimensioned range results in an error. Every element of a string array is initialized to an empty string by the DIM verb.

strname:template

Creates a simple string variable and associates it with a template. The template can be any string expression and describes the fields contained in the dimensioned string. A full discussion of templates can be found in the String Templates documentation.

ERR=lineref

Branch to be taken if an error occurs during execution.

dimensions may be 1 to 3 subscript ranges, separated by commas. Each subscript range has the following format:

{int:} int

When dimensioning a string array, the optional parenthetic argument may be used to initialize each element exactly as with simple strings; otherwise, each element is initialized to null. For porting older Business BASIC programs to PRO/5, parentheses may be used instead of brackets for numeric arrays. PRO/5 converts the parentheses to brackets automatically.

The same array may be redimensioned any number of times in PRO/5. Unlike older Business BASICs, PRO/5 will not completely remove an array if it is dimensioned to zero, DIM A[0], because it is the same as DIM A[0:0]. A one-element array is mathematically significant, and A[0:0] is as valid as A[6:6]. To remove an array, use the CLEAR verb.

PRO/5 evaluates the arguments for each item in a DIM statement before the items are dimensioned. In the statement DIM Z$(LEN(Z$)), the current length of Z$ is evaluated before the new Z$ is created.

Any size array may be dimensioned, but it must not exceed memory limits.

Note that matrix operations on numeric arrays are supported. See the LET Verb for more information on matrix operations.

Example

>DIM X[5,5,5]
0100 DIM A$(32000,$01$)
0200 DIM B$(9),X[2,3],A$(9,"A")
0300 DIM ARRAY$[10:20](10,"*")
0400 DIM REC$:TEMP$

See Also

Verbs - Alphabetical Listing