AddItem Method

Applies to TestComplete 15.70, last modified on December 17, 2024

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.AddItem method adds a new item with the specified Value to the end of the array. The AddItem method returns the ArrayItem object that provides a scripting interface to the item.

Declaration

ArrayObjectObj.AddItem(Value)

ArrayObjectObj An expression, variable or parameter that specifies a reference to an ArrayObject object
Value [in]    Optional    Variant Default value: empty   
Result An ArrayItem object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Value

Specifies the value of the new array item. This parameter can hold any Variant-compatible value: string, integer, date, object or it can be an array itself.

Result Value

The new array item, represented as an ArrayItem object.

Example

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

JavaScript, JScript

function AddItemOfArrayType()
{
   // Specifies the object
   var Obj = ODT.Classes.MyClass;
   // Adds a property of the array type
   // to the specified object
   var Prop = Obj.AddPropOfArrayType("MyProperty");
   // Adds three items to the MyProperty array
   Prop.AddItemOfArrayType;
   Prop.AddItem(258);
   Prop.AddItem("MyString");
   // ...
}

VBScript

Sub AddItemOfArrayType
   ' Specifies the object
   Set Obj = ODT.Classes.MyClass
   ' Adds a property of the array type
   ' to the specified object
   Set Prop = Obj.AddPropOfArrayType("MyProperty")
   ' Adds three items to the MyProperty array
   Prop.AddItemOfArrayType
   Prop.AddItem(258)
   Prop.AddItem("MyString")
   ' ...
End Sub

DelphiScript

function AddItemOfArrayType;
var Obj, Prop;
begin
   // Specifies the object
   Obj := ODT.Classes.MyClass;
   // Adds a property of the array type
   // to the specified object
   Prop := Obj.AddPropOfArrayType('MyProperty');
   // Adds three items to the MyProperty array
   Prop.AddItemOfArrayType;
   Prop.AddItem(258);
   Prop.AddItem('MyString');
   // ...
end;

C++Script, C#Script

function AddItemOfArrayType()
{
   // Specifies the object
   var Obj = ODT["Classes"]["MyClass"];
   // Adds a property of the array type
   // to the specified object
   var Prop = Obj["AddPropOfArrayType"]("MyProperty");
   // Adds three items to the MyProperty array
   Prop["AddItemOfArrayType"];
   Prop["AddItem"](258);
   Prop["AddItem"]("MyString");
   // ...
}

See Also

Items Property
AddItemOfArrayType Method
AddItemOfClassType Method
DeleteItem Method
AddItem Method

Highlight search results