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.Items
property returns the ArrayItem
object that provides access to the array item specified by its index. The total number of elements in the array is specified by the Count
property.
Note that the Items property is used by default and you can omit it in your scripts. Therefore, the following two lines are equivalent:
ArrayTypeObj(1)
Note: | If you use DelphiScript, you need to enclose Index in square brackets: Items[Index] . |
Declaration
ArrayTypeObj.Items(Index)
Read-Only Property | An ArrayItem object |
ArrayTypeObj | An expression, variable or parameter that specifies a reference to an ArrayType object | |||
Index | [in] | Required | Integer |
Applies To
The property is applied to the following object:
Parameters
The property has the following parameter:
Index
Specifies the index of the desired item in the array.
Property Value
The ArrayItem
object that provides access to the specified array item.
Remarks
To specify the item value, use the ArrayItem.Value
property. An array item can store any Variant-compatible value: string, integer, date, object, array, etc. The Value
property is used by default in the ArrayItem
object and you can omit it. Therefore, you can specify the item value in any of the following ways:
ArrayTypeObj.Items(1) = 10
ArrayTypeObj(1) = 10 // since both Value and Items are default properties
Note: | When you change the item value in an array that belongs to a class, TestComplete changes the item value in all the objects based on this class unless you have modified the item value in an object via script or manually. |
Example
The code below obtains information about the NewProperty property of the array type and then posts the values of all of its items to the test log.
JavaScript, JScript
function GetItemValue()
{
// Specifies the class to obtain information about
var Obj = ODT.Classes.MyClass;
// Specifies a property of the array type
var Prop = Obj.NewProperty;
// Iterates through the items
for (var i = 0; i < Prop.Count; i++)
{
var PrVal = Prop.Items(i).Value;
// Posts the current item's value to the test log
Log.Message("Item " + i + ": " + PrVal);
}
}
VBScript
Sub GetItemValue
' Specifies the class to obtain information about
Set Obj = ODT.Classes.MyClass
' Specifies a property of the array type
Set Prop = Obj.NewProperty
' Iterates through the items
For i = 0 to Prop.Count-1
PrVal = Prop.Items(i).Value
' Posts the current item's value to the test log
Log.Message("Item " & i & ": " & PrVal)
Next
End Sub
DelphiScript
function GetItemValue;
var Obj, Prop, i, PrVal;
begin
// Specifies the class to obtain information about
Obj := ODT.Classes.MyClass;
// Specifies a property of the array type
Prop := Obj.NewProperty;
// Iterates through the items
for i := 0 to Prop.Count-1 do
begin
PrVal := Prop.Items(i).Value;
// Posts the current item's value to the test log
Log.Message('Item ' + i + ': ' + PrVal);
end;
end;
C++Script, C#Script
function GetItemValue()
{
// Specifies the class to obtain information about
var Obj = ODT["Classes"]["MyClass"];
// Specifies a property of the array type
var Prop = Obj["NewProperty"];
// Iterates through the items
for (var i = 0; i < Prop["Count"]; i++)
{
var PrVal = Prop["Items"](i)["Value"];
// Posts the current item's value to the test log
Log["Message"]("Item " + i + ": " + PrVal);
}
}
See Also
Count Property
AddItem Method
AddItemOfArrayType Method
AddItemOfClassType Method
DeleteItem Method