Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem in looping statements...
05-15-2008, 10:58 AM
Post: #1
problem in looping statements...

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
Find all posts by this user
Quote this message in a reply
05-15-2008, 02:56 PM
Post: #2
RE: problem in looping statements...
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
Find all posts by this user
Quote this message in a reply
05-15-2008, 07:08 PM
Post: #3
RE: problem in looping statements...
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
Find all posts by this user
Quote this message in a reply
05-15-2008, 07:10 PM
Post: #4
RE: problem in looping statements...
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
Find all posts by this user
Quote this message in a reply
05-16-2008, 01:24 AM
Post: #5
RE: problem in looping statements...
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
Find all posts by this user
Quote this message in a reply
02-02-2012, 03:31 AM (This post was last modified: 02-02-2012 03:36 AM by siva.do.)
Post: #6
RE: problem in looping statements...
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
.
.
.
.
Find all posts by this user
Quote this message in a reply
02-02-2012, 02:23 PM
Post: #7
RE: problem in looping statements...
I think you have set "Run on all rows" option in file>settings>run
Change it to "one iteration only"
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Is there a better way to manage my If statements? mv8167 0 321 09-03-2011 01:14 AM
Last Post: mv8167
  Anyone know the difference of the 2 statements martinlam 3 674 08-31-2010 02:44 PM
Last Post: QTPLearn
  Looping wont stop laura 3 537 07-06-2009 02:11 PM
Last Post: basanth27
  Looping and seting value laura 5 606 07-03-2009 01:13 PM
Last Post: Ankur
  Conditional Statements from Data Table golfer999999 1 607 03-05-2009 08:43 PM
Last Post: sepgs2004

Forum Jump:


User(s) browsing this thread: 1 Guest(s)