QTP Forums

Full Version: problem in looping statements...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a datasheet containing 'n' number of rows...
i am trying to read the number of rows present in a datasheet and using For loop statement ... tried to get each row of data and able to perform my actions as per the requirements...

but my problem is that it is going to infinite loop after 'n' number of rows are done...

pls find the below piece of code...

For i=1 to rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next


so as to avoid infinite loop we can do
if i = rowcount
exit...

but the normal FOR syntax without any special checkings should work right...

can anyone tell me how to solve this with out using special checks apart from normal FOR syntax... or correct me if iam doing wrong in using FOR syntax


Thanks
Navya
Please check what is the value of rowcount using following syntax
msgbox rowcount
For i=1 to rowcount
msgbox rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next




navyasatish Wrote:Hi,

I have a datasheet containing 'n' number of rows...
i am trying to read the number of rows present in a datasheet and using For loop statement ... tried to get each row of data and able to perform my actions as per the requirements...

but my problem is that it is going to infinite loop after 'n' number of rows are done...

pls find the below piece of code...

For i=1 to rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next


so as to avoid infinite loop we can do
if i = rowcount
exit...

but the normal FOR syntax without any special checkings should work right...

can anyone tell me how to solve this with out using special checks apart from normal FOR syntax... or correct me if iam doing wrong in using FOR syntax


Thanks
Navya
Guest Wrote:Please check what is the value of rowcount using following syntax
msgbox rowcount
For i=1 to rowcount
msgbox rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next




navyasatish Wrote:sorry to mention that in my post ... i am getting the correct value only and i already did checked the rowcount value...
and it is comming correctly as per the rows present in the datasheet

problem is with infiniteloop only...


Thanks..
Navya
Hi,

I have a datasheet containing 'n' number of rows...
i am trying to read the number of rows present in a datasheet and using For loop statement ... tried to get each row of data and able to perform my actions as per the requirements...

but my problem is that it is going to infinite loop after 'n' number of rows are done...

pls find the below piece of code...

For i=1 to rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next


so as to avoid infinite loop we can do
if i = rowcount
exit...

but the normal FOR syntax without any special checkings should work right...

can anyone tell me how to solve this with out using special checks apart from normal FOR syntax... or correct me if iam doing wrong in using FOR syntax


Thanks
Navya
Guest Wrote:Please check what is the value of rowcount using following syntax
msgbox rowcount
For i=1 to rowcount
msgbox rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next



sorry to mention that in my post ... i am getting the correct value only and i already did checked the rowcount value...
and it is comming correctly as per the rows present in the datasheet

problem is with infiniteloop only...


Thanks..
Navya




navyasatish Wrote:Hi,

I have a datasheet containing 'n' number of rows...
i am trying to read the number of rows present in a datasheet and using For loop statement ... tried to get each row of data and able to perform my actions as per the requirements...

but my problem is that it is going to infinite loop after 'n' number of rows are done...

pls find the below piece of code...

For i=1 to rowcount
DataTable.SetCurrentRow(i)
statemnts...
.
.
.
Next


so as to avoid infinite loop we can do
if i = rowcount
exit...

but the normal FOR syntax without any special checkings should work right...

can anyone tell me how to solve this with out using special checks apart from normal FOR syntax... or correct me if iam doing wrong in using FOR syntax


Thanks
Navya
some have able to trace out the solution...


For i=1 to rowcount

DataTable.SetCurrentRow(i)
statements..
.
.
.
If i= rowcount Then
ExitTest
End If
Next

by using the above statement only i was able to comeout (infinite loop) of QTP...



Thanks
Navya
first use the getrowcount method to get number of used rows into a variable and then use it in the loop
eg x=datatable.localsheet or globalsheet.getrowcount
for i=1 to x step 1
.
.
.
.
I think you have set "Run on all rows" option in file>settings>run
Change it to "one iteration only"
Reference URL's