DeleteItem Method

Applies to TestComplete 14.10, last modified on June 5, 2019

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.DeleteItem method deletes an array item with the specified index. The total number of elements in the array is specified by the Count property.

Declaration

ArrayObjectObj.DeleteItem(Index)

ArrayObjectObj An expression, variable or parameter that specifies a reference to an ArrayObject object
Index [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Index

Specifies the index of the array item to be deleted. The first index in the array is 0, the second - 1, etc.

Result Value

None.

Remarks

You cannot delete items that were added to the ArrayType object on which ArrayObject is based. In other words, you cannot delete items from the “object” array if these items were declared in the “class” array. You can delete only those items that were added to the "object" array by the ArrayObject.AddItem, ArrayObject.AddItemOfArrayType or ArrayObject.AddItemOfClassType method. To delete items defined in the "class" array, use the ArrayType.DeleteItem method.

Example

The code below obtains information about the MyProperty property of the array type and then deletes all of its items with empty values.

JavaScript, JScript

function DeleteItem()
{
    // Specifies the property of the array type
    // to obtain information about
    var Prop = ODT.Classes.TestClass.MyProperty;
    // Iterates through the array items
    for (var i = 0; i < Prop.Count; i++)
       // Checks whether the current item's value is empty
       if ( Prop.Items(i).Value == aqObject.EmptyVariant )
         // Deletes the item
         Prop.DeleteItem(i);
}

VBScript

Sub DeleteItem
    ' Specifies the property of the array type
    ' to obtain information about
    Set Prop = ODT.Classes.TestClass.MyProperty
    ' Iterates through the array items
    For i = 0 to Prop.Count-1
       ' Checks whether the current item's value is empty
       If ( Prop.Items(i).Value = aqObject.EmptyVariant ) Then
         ' Deletes the item
         Prop.DeleteItem(i)
       End If
    Next
End Sub

DelphiScript

function DeleteItem;
var Prop, i;
begin
    // Specifies the property of the array type
    // to obtain information about
    Prop := ODT.Classes.TestClass.MyProperty;
    // Iterates through the array items
    for i := 0 to Prop.Count-1 do
       // Checks whether the current item's value is empty
       if ( Prop.Items(i).Value = aqObject.EmptyVariant ) then
         // Deletes the item
         Prop.DeleteItem(i);
end;

C++Script, C#Script

function DeleteItem()
{
    // Specifies the property of the array type
    // to obtain information about
    var Prop = ODT["Classes"]["TestClass"]["MyProperty"];
    // Iterates through the array items
    for (var i = 0; i < Prop["Count"]; i++)
       // Checks whether the current item's value is empty
       if ( Prop["Items"](i)["Value"] == aqObject["EmptyVariant"] )
         // Deletes the item
         Prop["DeleteItem"](i);
}

See Also

AddItem Method
AddItemOfArrayType Method
AddItemOfClassType Method
DeleteItem Method

Highlight search results