Survey Tabulation > Advanced expressions > UNICOM Intelligence function library > Categorical functions > ReDim
 
ReDim
Re-sizes an array to a given size. By default, the array contents are preserved, unless Preserve is set to False.
Syntax
ReDim(List, Size [, Preserve])
Parameters
List
Type: Categorical
Array or Categorical value.
Size
Type: Long
New size of the array.
Preserve
Type: Boolean
Defines whether to keep the existing contents. The default is True.
(return)
Type: Long
Always zero.
Remarks
This function changes the size of the last dimension of an array. If Preserve is False, all items in all dimensions are cleared. A Categorical value is treated as a one-dimensional array.
This function is similar to the ReDim function in Visual Basic.
Examples
The following mrScriptBasic example uses ReDim to redefine a categorical value without clearing it. UBound is used to return the upper bound value before and after calling ReDim.
Dim MyCategorical, x, y

MyCategorical = {1, 3, 5, 8}

x = UBound(MyCategorical)    ' Returns 3

ReDim(MyCategorical, 2)

y = UBound(MyCategorical)    ' Returns 1
In this next example, the Size parameter is set to 4 and the Preserve parameter is set to False.
Dim MyCategorical, x, y

MyCategorical = {1, 3, 5, 8}

ReDim(MyCategorical, 4, False)

z = UBound(MyCategorical)    ' Returns 3
See also
Categorical functions