AddVarOfArrayType 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 Group.AddVarOfArrayType method adds a new “array” variable to the group. “Array” means that this variable will store an array object. To create a variable that will store an object or an ordinary value, use the AddVarOfClassType and AddVariable methods.

Declaration

GroupObj.AddVarOfArrayType(VariableName)

GroupObj An expression, variable or parameter that specifies a reference to a Group object
VariableName [in]    Required    String    
Result An ArrayObject object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

VariableName

Specifies the variable name. This name must be unique within the group. If the group contains another variable with the specified name, an error occurs.

Result Value

The new variable represented as an ArrayObject object.

Example

The code below creates a new data group, adds a variable of the array type to the group and then adds new items to the created variable.

JavaScript, JScript

function AddVarOfArrayType()
{
  // Creates a data group
  var Group = ODT.Data.AddGroup("NewGroup");
  // Adds a variable of the array type to the group
  var Variable = Group.AddVarOfArrayType("NewVariable");
  // Adds new items to the created variable
  Variable.AddItem(123);
  Variable.AddItem("My_Text");
  //...
}

VBScript

Sub AddVarOfArrayType

  ' Creates a data group
  Set Group = ODT.Data.AddGroup("NewGroup")
  ' Adds a variable of the array type to the group
  Set Variable = Group.AddVarOfArrayType("NewVariable")
  ' Adds new items to the created variable
  Variable.AddItem(123)
  Variable.AddItem("My_Text")
  '...
End Sub

DelphiScript

function AddVarOfArrayType;
var Group, Variable;
begin

  // Creates a data group
  Group := ODT.Data.AddGroup('NewGroup');
  // Adds a variable of the array type to the group
  Variable := Group.AddVarOfArrayType('NewVariable');
  // Adds new items to the created variable
  Variable.AddItem(123);
  Variable.AddItem('My_Text');
  //...

end;

C++Script, C#Script

function AddVarOfArrayType()
{
  // Creates a data group
  var Group = ODT["Data"]["AddGroup"]("NewGroup");
  // Adds a variable of the array type to the group
  var Variable = Group["AddVarOfArrayType"]("NewVariable");
  // Adds new items to the created variable
  Variable["AddItem"](123);
  Variable["AddItem"]("My_Text");
  //...
}

See Also

AddVariable Method
AddVarOfClassType Method
DeleteVariable Method
Variables Property

Highlight search results