Developer Documentation Library > 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 value is True.
(return)
Type: Long
Always zero.
Notes
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 the following 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