Size of variable-size arrays

General information

A variable-size array consists of a variable name followed by square brackets but no number. PocketBuilder defines the array elements by use at execution time (subject only to memory constraints). Only one-dimensional arrays can be variable-size arrays.

Because you do not declare the size, you cannot use the TO notation to change the lower bound of the array, so the lower bound of a variable-size array is always 1.

How memory is allocated

Initializing elements of a variable-size array allocates memory for those elements. You specify initial values just as you do for fixed-size arrays, by listing the values in braces. The following statement sets code[1] equal to 11, code[2] equal to 242, and code[3] equal to 27. The array has a size of 3 initially, but the size will change if you assign values to higher positions:

integer li_code[ ]={11,242,27}

For example, these statements declare a variable-size array and assigns values to three array elements:

long ll_price[ ]

ll_price[100] = 2000

ll_price[50]  = 3000

ll_price[110] = 5000

When these statements first execute, they allocate memory as follows: