cancel
Showing results for 
Search instead for 
Did you mean: 

Table variables - retrieve row number using the Iterator

SOLVED
simonaferrara
Contributor

Table variables - retrieve row number using the Iterator

Hi all,

 

I'm working with Table variables: https://support.smartbear.com/testcomplete/docs/testing-with/variables/data-types/table.html

 

and executing a loop to get the variable values using the Iterator object (see below for the code).

I need to have, within the loop, the row number that the iterator is processing, but I've not found a way to retrieve it. How can I retrieve the actual row number into the loop?

 

This is the code (I've simplified it to let you easily understand):

 

let table = <keywordtest var>;
let iterator = table.Iterator;

iterator.Reset();

while (!iterator.IsEOF())
{
        firstColumnValue = iterator.Value(<firstColumn>);
        secondColumnValue = iterator.Value(<secondColumn>);
       

        //here I would like to retrieve the actual row number that the iterator is processing


        iterator.Next();
}

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Table variables - retrieve row number using the Iterator

Hi,

 

to retrieve the actual row number that the iterator is processing

Iterator object does not provide such property, so you'll need to implement it yourself:

iterator.Reset();

let iRowNo = 0;

while (!iterator.IsEOF())
{
        firstColumnValue = iterator.Value(<firstColumn>);
        secondColumnValue = iterator.Value(<secondColumn>);
       

        //here I would like to retrieve the actual row number that the iterator is processing

        Log.Message(iRowNo);


        iterator.Next();

        iRowNo++;
}

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

2 REPLIES 2
AlexKaras
Community Hero

Re: Table variables - retrieve row number using the Iterator

Hi,

 

to retrieve the actual row number that the iterator is processing

Iterator object does not provide such property, so you'll need to implement it yourself:

iterator.Reset();

let iRowNo = 0;

while (!iterator.IsEOF())
{
        firstColumnValue = iterator.Value(<firstColumn>);
        secondColumnValue = iterator.Value(<secondColumn>);
       

        //here I would like to retrieve the actual row number that the iterator is processing

        Log.Message(iRowNo);


        iterator.Next();

        iRowNo++;
}

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

simonaferrara
Contributor

Re: Table variables - retrieve row number using the Iterator

Thank you @AlexKaras  !

New Here?
Join us and watch the welcome video:
Top Kudoed Authors