Index Property (ArrayItem Objects)

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 ArrayItem.Index property specifies the item index in the array. The first item has index 0, the second - 1, etc. The total number of items in the array is specified by the array's Count property.

Declaration

ArrayItemObj.Index

Read-Only Property Integer
ArrayItemObj An expression, variable or parameter that specifies a reference to an ArrayItem object

Applies To

The property is applied to the following object:

Property Value

The item index in the array.

Example

The code below obtains the collection of elements that belong to the specified array and then posts the elements' indexes and values to the test log.

JavaScript, JScript

function ArrayItem()
{
   // Obtains information about the MyClass class
   var PrCol = ODT.Classes.MyClass;
   for (vari = 0; i < PrCol.Property1.Count; i++)
   {
     // Obtains the index of the array element
     var PrIndex = PrCol.Property1.Items(i).Index;
     // Obtains the value of the array element
     var PrValue = PrCol.Property1.Items(i).Value;
     // Posts the element's index and value to the test log
     Log.Message((PrIndex+1) + " array element: " + PrValue);
   }
}

VBScript

Sub ArrayItem
   ' Obtains information about the MyClass class
   Set PrCol = ODT.Classes.MyClass
   For i = 0 to PrCol.Property1.Count-1
     ' Obtains the index of the array element
     PrIndex = PrCol.Property1.Items(i).Index
     ' Obtains the value of the array element
     PrValue = PrCol.Property1.Items(i).Value
     ' Posts the element's index and value to the test log
     Log.Message(PrIndex+1 & " array element: " & PrValue)
   Next
End Sub

DelphiScript

function ArrayItem;
var PrCol, i, PrIndex, PrValue;
begin
   // Obtains information about the MyClass class
   PrCol := ODT.Classes.MyClass;
   for i := 0 to PrCol.Property1.Count-1 do
   begin
     // Obtains the index of the array element
     PrIndex := PrCol.Property1.Items(i).Index;
     // Obtains the value of the array element
     PrValue := PrCol.Property1.Items(i).Value;
     // Posts the element's index and value to the test log
     Log.Message((PrIndex+1) + ' array element: ' + PrValue);
   end;
end;

C++Script, C#Script

function ArrayItem()
{
   // Obtains information about the MyClass class
   var PrCol = ODT["Classes"]["MyClass"];
   for (vari = 0; i < PrCol["Property1"]["Count"]; i++)
   {
     // Obtains the index of the array element
     var PrIndex = PrCol["Property1"]["Items"](i)["Index"];
     // Obtains the value of the array element
     var PrValue = PrCol["Property1"]["Items"](i)["Value"];
     // Posts the element's index and value to the test log
     Log["Message"]( (PrIndex+1) + " array element: " + PrValue );
   }
}

See Also

Name Property
Count Property
Count Property

Highlight search results