AddItemOfArrayType Method

Applies to TestComplete 15.44, last modified on November 10, 2022

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 ArrayType.AddItemOfArrayType method adds a new item, which will be an array itself, to the end of the array. When you add an item to the array in a class, a new item is added or inserted into the appropriate position in arrays in all the objects that are based on this class.

Declaration

ArrayTypeObj.AddItemOfArrayType()

ArrayTypeObj An expression, variable or parameter that specifies a reference to an ArrayType object
Result An ArrayType object

Applies To

The method is applied to the following object:

Result Value

The new array item represented as an ArrayType object.

Example

The code below adds a new MyProperty property of the array type to the specified class and then adds three new items to the created property.

JavaScript, JScript

function ArrayTypeExample()
{
    // Creates a new class
    var Obj = ODT.Classes.Declare("MyClass");
    // Adds a new property of the array type to the class
    var Prop = Obj.AddPropOfArrayType("MyProperty");
    // Adds three items to the MyProperty property
    Prop.AddItem(159);
    Prop.AddItem("Hello, world.");
    var ArrItem = Prop.AddItemOfArrayType;
    // ...
}

VBScript

Sub ArrayTypeExample
    ' Creates a new class
    Set Obj = ODT.Classes.Declare("MyClass")
    ' Adds a new property of the array type to the class
    Set Prop = Obj.AddPropOfArrayType("MyProperty")
    ' Adds three items to the MyProperty property
    Prop.AddItem(159)
    Prop.AddItem("Hello, world.")
    Set ArrItem = Prop.AddItemOfArrayType
    ' ...
End Sub

DelphiScript

function ArrayTypeExample;
var Obj, Prop, ArrItem;
begin
    // Creates a new class
    Obj := ODT.Classes.Declare('MyClass');
    // Adds a new property of the array type to the class
    Prop := Obj.AddPropOfArrayType('MyProperty');
    // Adds three items to the MyProperty property
    Prop.AddItem(159);
    Prop.AddItem('Hello, world.');
    ArrItem := Prop.AddItemOfArrayType;
    // ...
end;

C++Script, C#Script

function ArrayTypeExample()
{
    // Creates a new class
    var Obj = ODT["Classes"]["Declare"]("MyClass");
    // Adds a new property of the array type to the class
    var Prop = Obj["AddPropOfArrayType"]("MyProperty");
    // Adds three items to the MyProperty property
    Prop["AddItem"](159);
    Prop["AddItem"]("Hello, world.");
    var ArrItem = Prop["AddItemOfArrayType"];
    // ...
}

See Also

Items Property
AddItem Method
AddItemOfClassType Method
DeleteItem Method
AddItemOfArrayType Method

Highlight search results