Reset Method

Applies to TestComplete 14.61, last modified on April 22, 2021

Description

The Reset method sets the Table variable’s iterator to the initial position - on the first data row.

Declaration

IteratorObj.Reset()

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

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

After a call to Reset, the iterator is on the first row of the array. There is no need to call Next to navigate to the first 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
Next Method
IsEOF Method

Highlight search results