IsEOF Method

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

Description

The IsEOF method specifies whether the Table variable’s iterator is at the end of the array and further iteration is impossible.

Declaration

IteratorObj.IsEOF()

IteratorObj An expression, variable or parameter that specifies a reference to an Iterator object
Result Boolean

Applies To

The method is applied to the following object:

Result Value

If the iterator is at the end of the array (after the last row), the method returns True; otherwise, it returns False.

Remarks

Use the IsEOF method along with the Reset and Next methods to iterate through data rows. Reset sets the iterator to the initial position. Next forwards the iterator to the next row.

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
Reset Method
Next Method

Highlight search results