Value Property

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

Description

Use the Value property to obtain a column's value from the current row IteratorObj provides access to.

Declaration

IteratorObj.Value(Column)

Read-Only Property Variant
IteratorObj An expression, variable or parameter that specifies a reference to an Iterator object
Column [in]    Required    String    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Column

Specifies the name of the needed column. To determine column names, you can use the ColumnName property of the TableVariable object. This property returns the column name by the column's index (zero-based).

If the specified column does not exist, an error occurs.

Note:

If you use Python or DelphiScript, you should enclose the parameter of the Value property in square brackets: Value[Column].

Property Value

The value of the specified column.

Remarks

The Iterator object contains methods that let you iterate through data rows. The Value property specifies the column values of the current data row. To iterate through rows, use the Next, IsEOF and Reset methods. See Variables of the Table Type.

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
Next Method
Reset Method
IsEOF Method
ColumnName Property
ColumnCount Property

Highlight search results