DeleteItem 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

Deletes an array item with the specified index. The total number of elements in the array is specified by the Count property. When you delete an item from the array in a class, the appropriate items are also deleted from arrays in the objects that are based on this class.

Declaration

ArrayTypeObj.DeleteItem(Index)

ArrayTypeObj An expression, variable or parameter that specifies a reference to an ArrayType 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.

Example

The code below obtains information about the MyProperty property of the array type and then deletes all of its items that have 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

Items Property
AddItem Method
AddItemOfArrayType Method
AddItemOfClassType Method
DeleteItem Method

Highlight search results