AddPropOfArrayType 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 Class.AddPropOfArrayType method adds a new array property to the class and returns this property as the ArrayType object. You can then use this object to add items to or delete them from an array.

Declaration

ClassObj.AddPropOfArrayType(Name)

ClassObj An expression, variable or parameter that specifies a reference to a Class object
Name [in]    Required    String    
Result An ArrayType object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Name

Specifies the name of the new property. The property name must be unique within the class. If the class already contains a method or property with the specified name, an error will occur. Since the property name is used to address the property in scripts, it must match the naming rules of the selected scripting language (it must be a valid identifier).

Result Value

The new property represented as an ArrayType object.

Remarks

When you add a new property to the class, it is also added to all the existing objects that are based on this class. The “object” arrays will contain the same items that the “class” array has.

Example

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

JavaScript, JScript

function ArrayTypeExample()
{
    // Creates a new class
    var Obj = ODT.Classes.Declare("MyClass");
    // Adds a new property of the array type to the class
    var Prop = Obj.AddPropOfArrayType("MyProperty");
    // Adds three items to the MyProperty property
    Prop.AddItem(159);
    Prop.AddItem("Hello, world.");
    var ArrItem = Prop.AddItemOfArrayType;
    // ...
}

VBScript

Sub ArrayTypeExample
    ' Creates a new class
    Set Obj = ODT.Classes.Declare("MyClass")
    ' Adds a new property of the array type to the class
    Set Prop = Obj.AddPropOfArrayType("MyProperty")
    ' Adds three items to the MyProperty property
    Prop.AddItem(159)
    Prop.AddItem("Hello, world.")
    Set ArrItem = Prop.AddItemOfArrayType
    ' ...
End Sub

DelphiScript

function ArrayTypeExample;
var Obj, Prop, ArrItem;
begin
    // Creates a new class
    Obj := ODT.Classes.Declare('MyClass');
    // Adds a new property of the array type to the class
    Prop := Obj.AddPropOfArrayType('MyProperty');
    // Adds three items to the MyProperty property
    Prop.AddItem(159);
    Prop.AddItem('Hello, world.');
    ArrItem := Prop.AddItemOfArrayType;
    // ...
end;

C++Script, C#Script

function ArrayTypeExample()
{
    // Creates a new class
    var Obj = ODT["Classes"]["Declare"]("MyClass");
    // Adds a new property of the array type to the class
    var Prop = Obj["AddPropOfArrayType"]("MyProperty");
    // Adds three items to the MyProperty property
    Prop["AddItem"](159);
    Prop["AddItem"]("Hello, world.");
    var ArrItem = Prop["AddItemOfArrayType"];
    // ...
}

See Also

AddProperty Method
AddPropOfClassType Method
DeleteProperty Method
Properties Property
AddPropOfArrayType Method

Highlight search results