LOTUSSCRIPT LANGUAGE


ReDim statement
Example

Declares a dynamic array and allocates storage for it, or resizes an existing dynamic array.

Syntax

ReDim [ Preserve ] arrayName ( bounds ) [ As type]

[ , arrayName ( bounds ) [ As type ] ] ...

Elements

Preserve

arrayName
bounds
type
Usage

A ReDim statement allocates storage for a dynamic array. You can resize the array with additional ReDim statements as often as you want. Each time you resize the array, LotusScript reallocates the storage for it.

Unlike a Dim statement, ReDim cannot specify an array as Private, Public, or Static. To specify a dynamic array with one of these characteristics, declare it first in a Dim statement. If you declare a dynamic array with a Dim statement, LotusScript doesn't allocate storage for the array elements. You can’t actually use the array in your script until you allocate storage with ReDim.

Arrays can have up to 8 dimensions. The first ReDim statement for an array sets the number of dimensions for the array. Subsequent ReDim statements for the array can change the upper and lower bounds for each dimension, but not the number of dimensions.

If Preserve is specified, you can change only the upper bound of the last array dimension. Attempting to change any other bound results in an error.

Do not use ReDim on a fixed array (an array already declared and allocated by a Dim statement).

If you're using ForAll on a container variable that is an array of arrays, do not ReDim the reference variable (this generates the "Illegal ReDim" error).

Example
See Also