BuiltIn.VarArrayRedim Method

Applies to TestComplete 15.46, last modified on January 09, 2023

Description

The VarArrayRedim method resizes the Arr array, which must be created with the CreateVariantArray, CreateVariantArray2 or CreateVariantArray3 function. Existing array elements are preserved.

This method is available if the BuiltIn plugin is installed and enabled. The plugin is installed and enabled by default.

Declaration

BuiltIn.VarArrayRedim(Arr, HighBound)

Arr [in, out]    Required    Variant    
HighBound [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Arr

The desired array whose elements are of the Variant type.

HighBound

A new high bound of the rightmost dimension in Arr.

Result Value

None.

Remarks

Currently, the VarArrayRedim method works only in VBScript and DelphiScript. This is because it returns a resized array via the out parameter which is not supported in JavaScript, JScript, Python, C#Script and C++Script.

The VarArrayRedim method does not work for arrays created in other units. However, you can work around this limitation by copying the array to a local variable, calling the VarArrayRedim method over the local array and then assigning the resized array to the initial variable.

Example

Below is a code snippet that increments the array size using this workaround:

JavaScript

The JavaScript example is not available, because the VarArrayRedim method is not supported in this language.

JScript

The JScript example is not available, because the VarArrayRedim method is not supported in this language.

Python

The Python example is not available, because the VarArrayRedim method is not supported in this language.

VBScript

'USEINIT Unit2 ' In this unit, the Arr array is created

...

Dim tmp, n

tmp = Arr
n = BuiltIn.VarArrayHighBound(tmp, 1)
Call BuiltIn.VarArrayRedim(tmp, n + 1)
Arr = tmp

DelphiScript

uses Unit2; // In this unit, the Arr array is created

...

var
  tmp, n: OleVariant;
begin
  tmp := Arr;
  n := BuiltIn.VarArrayHighBound(tmp, 1);
  BuiltIn.VarArrayRedim(tmp, n + 1);
  Arr := tmp;
end;

C++Script, C#Script

The C#Script and C++Script examples are not available, because the VarArrayRedim method is not supported in these languages.

See Also

CreateVariantArray Method
CreateVariantArray2 Method
CreateVariantArray3 Method
VarArrayHighBound Method
VarArrayLowBound Method

Highlight search results