ArrayObject Object

Applies to TestComplete 15.47, last modified on January 20, 2023

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

Description

The ArrayObject object is used to create array properties in objects that are created via the ODT project item. Normally, ArrayObject is created on the basis of the ArrayType object used to create array properties in classes. For instance, if you add an array property to a class and then add ten items to the array, all the objects that are based on this class will have an array property with ten items in the array. Using methods and properties of the ArrayObject object, you can add then more items to the “object” arrays.

An array item can store any OLEVariant value. It can hold a string, an integer, a reference to an object or can be an array itself.

The ArrayObject objects are created when you create objects that are based on classes containing the array properties. The ArrayObject object is also created when you call the Object.AddPropOfArrayType method.

Members

Example

The code below creates a new data group, adds a property of the array type to it and then adds two items to the created property.

JavaScript, JScript

function ArrayObjExample()
{
     // Adds a new data group
    var Data = ODT.Data.AddGroup("TestData");
    // Adds a new variable of the MyClass class type
    var sVar = Data.AddVarOfClassType("TestVar", "MyClass");
    // Adds a new property of the array type to the TestVar variable
    var Prop = sVar.AddPropOfArrayType("MyProperty");
    // Adds two items to the MyProperty property
    Prop.AddItem(123);
    Prop.AddItem("MyString");
}

VBScript

Sub ArrayObjExample
     ' Adds a new data group
    Set Data = ODT.Data.AddGroup("TestData")
    ' Adds a new variable of the MyClass class type
    Set sVar = Data.AddVarOfClassType("TestVar", "MyClass")
    ' Adds a new property of the array type to the TestVar variable
    Set Prop = sVar.AddPropOfArrayType("MyProperty")
    ' Adds two items to the MyProperty property
    Prop.AddItem(123)
    Prop.AddItem("MyString")
End Sub

DelphiScript

function ArrayObjExample;
var Data, sVar, Prop;
begin
     // Adds a new data group
    Data := ODT.Data.AddGroup('TestData');
    // Adds a new variable of the MyClass class type
    sVar := Data.AddVarOfClassType('TestVar', 'MyClass');
    // Adds a new property of the array type to the TestVar variable
    Prop := sVar.AddPropOfArrayType('MyProperty');
    // Adds two items to the MyProperty property
    Prop.AddItem(123);
    Prop.AddItem('MyString');
end;

C++Script, C#Script

function ArrayObjExample()
{
     // Adds a new data group
    var Data = ODT["Data"]["AddGroup"]("TestData");
    // Adds a new variable of the MyClass class type
    var sVar = Data["AddVarOfClassType"]( "TestVar", "MyClass" );
    // Adds a new property of the array type to the TestVar variable
    var Prop = sVar["AddPropOfArrayType"]("MyProperty");
    // Adds two items to the MyProperty property
    Prop["AddItem"](123);
    Prop["AddItem"]("MyString");
}

See Also

AddPropOfArrayType Method
ArrayType Object

Highlight search results