TableVariable Object

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The TableVariable object provides a program interface to an array that is stored in a variable of the Table type. Specific members of this object are listed below.

When you are specifying the names of array columns from the Variables page, TestComplete adds additional properties to the TableVariable object. These properties allow you to obtain the value of the desired element of the array. The properties are named as columns and have the Index parameter. You use this parameter to specify the row that contains the desired element.

Members

Example

The code below demonstrates how you can iterate through the rows of an array stored in a Table variable.

JavaScript, JScript

function Test1()
{
  var MyVar, Iterator, ColName, value;
  MyVar = Project.Variables.MyTableVar; 
  Iterator = MyVar.Iterator;
  
  // Initializes the iterator
  Iterator.Reset();
  
  // Iterates through the rows
  while (!Iterator.IsEOF())
  {
    // Returns the column name by its index
    ColName = MyVar.ColumnName(1);
    
    // Retrieves values and posts them to the log    
    value = Iterator.Value(ColName);
    Log.Message(value);  
    
    // Forwards the iterator to the next row
    Iterator.Next();
  }
}

Python

def Test1():
  MyVar = Project.Variables.MyTableVar
  Iterator = MyVar.Iterator
  # Initializes the iterator
  Iterator.Reset()
  # Iterates through the rows 
  while not Iterator.IsEOF():
    # Returns the column name by its index 
    ColName = MyVar.ColumnName[1]
    # Retrieves values and posts them to the log     
    value = Iterator.Value[ColName]
    Log.Message(value)
    # Forwards the iterator to the next row 
    Iterator.Next()

VBScript

Sub Test1
  Set MyVar = Project.Variables.MyTableVar 
  Set Iterator = MyVar.Iterator
  
  ' Initializes the iterator
  Call Iterator.Reset
  
  ' Iterates through the rows
  While Not Iterator.IsEOF
    ' Returns the column name by its index
    Set ColName = MyVar.ColumnName(1)
    
    ' Retrieves values and posts them to the log    
    value = Iterator.Value(ColName)
    Log.Message(value)  
    
    ' Forwards the iterator to the next row
    Iterator.Next
  WEnd
End Sub

DelphiScript

procedure Test1;
var
  MyVar, Iterator, ColName, value: OleVariant;
begin
  MyVar := Project.Variables.MyTableVar; 
  Iterator := MyVar.Iterator;
  
  // Initializes the iterator
  Iterator.Reset();
  
  // Iterates through the rows
  while not Iterator.IsEOF()do
  begin
    //Returns the column name by its index
    ColName := MyVar.ColumnName(1);
    
    // Retrieves values and posts them to the log    
    value := Iterator.Value[ColName];
    Log.Message(value);  
    
    // Forwards the iterator to the next row
    Iterator.Next();
  end;
end;

C++Script, C#Script

function Test1()
{
  var MyVar, Iterator, ColName, value;
  MyVar = Project["Variables"]["MyTableVar"]; 
  Iterator = MyVar["Iterator"];
  
  // Initializes the iterator
  Iterator["Reset"]();
  
  // Iterates through the rows
  while (!Iterator["IsEOF"]())
  {
    // Returns the column name by its index
    ColName = MyVar["ColumnName"](1);
    
    // Retrieves values and posts them to the log    
    value = Iterator["Value"](ColName);
    Log["Message"](value);  
    
    // Forwards the iterator to the next row
    Iterator["Next"]();
  }
}

See Also

Variables of the Table Type
Variables Page

Highlight search results