beautypg.com

Remote Processing CAMBASIC User Manual

Page 66

background image

Comm ands - 33

DIM

Statement

SYNTAX:

D I M variable (value) [, variable (value)] . . .

PURPOSE:

To specify the maximum size for ar ray variables and reserve m emory accor dingly.

REMARK S:

The DIM statement sets all elements of the specified numerical arrays to an initial value of zero.
String array elements are of var iable length, with an initial value of zero (null).

The default value is 11 for numerical values and 253 for strings. This means that the numerical
array subscripts for 0 to 10 are allowed. The number of subscr ipts is always one more than the
dimension. The m aximum number of dimensions for an array is 255.

NOTE:

When CL EAR is executed, all dimensioned arrays are redim ensioned to 11

(0– 10).

NOTE:

String arrays are single dimension only.

U n li ke s ca l ar v a ri a bl e s, d i m en s io n ed a r ra y na m e s u s e o n ly th e fi r st an d la s t l et te r s. A v a r ia b le n am e
PUMP(n) is seen as the same as PP(n) and returns the same number.

EXAMPLE:

The following dimensions a single dimension numeric and string array:

10 DIM A(25), A$(30)

The following dim ensions a numer ic array w ith three dimensions:

20 DIM B(10,10,10)

ERROR:

< Out of memory> – if dimensioned space exceeds memory
< Data negative> – if value is negative
< Array already dimensioned> – if an attempt is made to redimension an array or dimension an
arra y that has alr eady been refer enced in the e xecution path