BuiltIn.CreateVariantArray2 Method

Applies to TestComplete 14.70, last modified on April 22, 2021

Description

The CreateVariantArray2 method lets you create a new two-dimensional array whose elements will have the Variant type.

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

Declaration

BuiltIn.CreateVariantArray2(Low1High1Low2High2)

Low1 [in]    Required    Integer    
High1 [in]    Required    Integer    
Low2 [in]    Required    Integer    
High2 [in]    Required    Integer    
Result Variant

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Low1

The lowest array index of the array's first dimension.

High1

The highest array index of the array's first dimension.

Low2

The lowest array index of the array's second dimension.

High2

The highest array index of the array's second dimension.

Result Value

The created array.

Remarks

The array format adopted in JavaScript, JScript, Python, C#Script and C++Script languages differs from the format of arrays created with this routine. These scripting languages' arrays are objects, while the CreateVariantArray2 method produces variant arrays. The elements of variant arrays cannot be assigned directly from JavaScript, JScript, Python, C#Script or C++Script. TestComplete supports Python arrays, and there is no need to use variant arrays.

There was a workaround for one-dimensional arrays: an ordinary JavaScript or JScript array was created, filled with values and then converted to a variant array. See the Remarks section in the BuiltIn.CreateVariantArray topic for details. Unfortunately, this trick does not work for multidimensional arrays. This happens, because, in JavaScript and JScript, multidimensional arrays are emulated by arrays of arrays, thus the ConvertJScriptArray routine will return a one-dimensional array that contains other arrays as its items.

Example

VBScript

' Creates a two-dimensional array [0..2, 3..4]
w = CreateVariantArray2(0, 2, 3, 4)
w(0,3) = "Element 0,3"
w(0,4) = "Element 0,4"
w(1,4) = "Element 1,4"
w(2,3) = "Element 2,3"

DelphiScript

// Creates a two-dimensional array [0..2, 3..4]
w := CreateVariantArray2(0, 2, 3, 4);
w[0,3] := 'Element 0,3';
w[0,4] := 'Element 0,4';
w[1,4] := 'Element 1,4';
w[2,3] := 'Element 2,3';

See Also

BuiltIn.CreateVariantArray
BuiltIn.CreateVariantArray3
BuiltIn.VarArrayRedim
BuiltIn.VarArrayLowBound
BuiltIn.VarArrayHighBound

Highlight search results