Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get out of infinite FOR loop...
#1
Not Solved
I am importing the data from the excel sheet for input and using for loop to put in the different values but at the end of the data in excel it starts again.How can I make it stop from going into the infinite FOR loop.Code is as following


Code:
datatable.Import("C:\Path")
rowcount=DataTable.GetRowCount


For r=1 to rowcount

DataTable.SetCurrentRow( r )


systemutil.Run"C:\Program Files (x86)\Internet Explorer\iexplore.exe"

Browser("Browser").WinEdit("Edit").Set "URL"

Browser("Browser").WinToolbar("Page Control").Click(button)

Browser("Browser").Page("AWB - Current Status").WebEdit("airWayBillTrackingNo").Set DataTable("AWBno", dtGlobalSheet)

Browser("Browser").Page("AWB - Current Status").WebButton("Track").Click(button)


'Browser("Browser").Sync

'-----a = Browser("Browser").Page("AWB - Current Status").Check (CheckPoint("AWB - Current Status_2"))

'---------msgbox("The Error for blank AWB : " & a)
'------Browser("Browser").Sync

'-------Browser("Browser").Page("AWB - Current Status_2").Link("Modify Search").Click

'---------b= Browser("AWB - Current Status").Page("AWB - Current Status").Check (CheckPoint("AWB - Current Status"))

'----------msgbox("The Error for AWB not found or only numbers : "& b)



'TODO:Check
strText=Browser("Browser").Page("AWB - Current Status").WebElement("AWB").GetROProperty("innertext")

strText1=Browser("Browser").Page("AWB - Current Status").WebElement("AWBO").GetROProperty("innertext")

strText2=Browser("Browser").Page("AWB - Current Status").WebElement("AWBD").GetROProperty("innertext")

strText3=Browser("Browser").Page("AWB - Current Status").WebElement("FlightD").GetROProperty("innertext")

strText4=Browser("Browser").Page("AWB - Current Status").WebElement("FlightDate").GetROProperty("innertext")

strText5=Browser("Browser").Page("AWB - Current Status").WebElement("Flightno").GetROProperty("innertext")

strText6=Browser("Browser").Page("AWB - Current Status").WebElement("FlightO").GetROProperty("innertext")

strText7=Browser("Browser").Page("AWB - Current Status").WebElement("FlightTime").GetROProperty("innertext")

strText8=Browser("Browser").Page("AWB - Current Status").WebElement("CurrentStatus").GetROProperty("innertext")
'Create Excel app
Set objAppExcel=CreateObject("Excel.Application")
objAppExcel.visible=True
'Open the worksbook
objAppExcel.workbooks.open "C:\Users\User\Desktop\TRACK.xls"
'Set focus on the workbook
objAppExcel.Workbooks("TRACK.xls").Activate
'Create work sheet obj
Set objExcelSheet=objAppExcel.ActiveWorkbook.Worksheets(1)
'Write to work sheet

'Save worksheet
'objExcelSheet.saveAs "C:\Users\User\Desktop\TRACK.xls"
'Clear  obj reference
'----Set objExcelSheet=Nothing
'quit app
'----objAppExcel.quit
'-----Set objAppExcel=Nothing


'Write to work sheet
objExcelSheet.cells(1,1)=strText

objExcelSheet.cells(1,2)=strText1



objExcelSheet.cells(1,3)=strText2



objExcelSheet.cells(1,4)=strText3



objExcelSheet.cells(1,5)=strText4



objExcelSheet.cells(1,6)=strText5



objExcelSheet.cells(1,7)=strText6



objExcelSheet.cells(1,8)=strText7



objExcelSheet.cells(1,9)=strText8
'Save worksheet
objExcelSheet.saveAs "C:\Users\User\Desktop\TRACK.xls"
'Clear  obj reference
Set objExcelSheet=Nothing
'quit app
objAppExcel.quit
Set objAppExcel=Nothing

Browser("Browser").Close


Next
Reply
#2
Not Solved
Plz Use 'Exit For'
Reply
#3
Not Solved
Hey it is still not working I am using the following code


Code:
datatable.Import("C:\Path")
rowcount=DataTable.GetRowCount


For r=1 to rowcount

DataTable.SetCurrentRow(r)


systemutil.Run"C:\Program Files (x86)\Internet Explorer\iexplore.exe"

Browser("Browser").WinEdit("Edit").Set "http://URL"

Browser("Browser").WinToolbar("Page Control").Click(button)

Browser("Browser").Page("AWB - Current Status").WebEdit("airWayBillTrackingNo").Set DataTable("AWBno", dtGlobalSheet)

Browser("Browser").Page("AWB - Current Status").WebButton("Track").Click(button)


'Browser("Browser").Sync

'-----a = Browser("Browser").Page("AWB - Current Status").Check (CheckPoint("AWB - Current Status_2"))

'---------msgbox("The Error for blank AWB : " & a)
'------Browser("Browser").Sync

'-------Browser("Browser").Page("AWB - Current Status_2").Link("Modify Search").Click

'---------b= Browser("AWB - Current Status").Page("AWB - Current Status").Check (CheckPoint("AWB - Current Status"))

'----------msgbox("The Error for AWB not found or only numbers : "& b)



'TODO:Check
strText=Browser("Browser").Page("AWB - Current Status").WebElement("AWB").GetROProperty("innertext")

strText1=Browser("Browser").Page("AWB - Current Status").WebElement("AWBO").GetROProperty("innertext")

strText2=Browser("Browser").Page("AWB - Current Status").WebElement("AWBD").GetROProperty("innertext")

strText3=Browser("Browser").Page("AWB - Current Status").WebElement("FlightD").GetROProperty("innertext")

strText4=Browser("Browser").Page("AWB - Current Status").WebElement("FlightDate").GetROProperty("innertext")

strText5=Browser("Browser").Page("AWB - Current Status").WebElement("Flightno").GetROProperty("innertext")

strText6=Browser("Browser").Page("AWB - Current Status").WebElement("FlightO").GetROProperty("innertext")

strText7=Browser("Browser").Page("AWB - Current Status").WebElement("FlightTime").GetROProperty("innertext")

strText8=Browser("Browser").Page("AWB - Current Status").WebElement("CurrentStatus").GetROProperty("innertext")
'Create Excel app
Set objAppExcel=CreateObject("Excel.Application")
objAppExcel.visible=True
'Open the worksbook
objAppExcel.workbooks.open "C:\Users\User\Desktop\TRACK.xls"
'Set focus on the workbook
objAppExcel.Workbooks("TRACK.xls").Activate
'Create work sheet obj
Set objExcelSheet=objAppExcel.ActiveWorkbook.Worksheets(1)
'Write to work sheet

'Save worksheet
'objExcelSheet.saveAs "C:\Users\User\Desktop\TRACK.xls"
'Clear  obj reference
'----Set objExcelSheet=Nothing
'quit app
'----objAppExcel.quit
'-----Set objAppExcel=Nothing


'Write to work sheet
objExcelSheet.cells(r,1)=strText

objExcelSheet.cells(r,2)=strText1



objExcelSheet.cells(r,3)=strText2



objExcelSheet.cells(r,4)=strText3



objExcelSheet.cells(r,5)=strText4



objExcelSheet.cells(r,6)=strText5



objExcelSheet.cells(r,7)=strText6



objExcelSheet.cells(r,8)=strText7



objExcelSheet.cells(r,9)=strText8
'Save worksheet
objExcelSheet.saveAs "C:\Users\User\Desktop\TRACK.xls"
'Clear  obj reference
Set objExcelSheet=Nothing
'quit app
objAppExcel.quit
Set objAppExcel=Nothing

Browser("Browser").Close
If r=("2") Then

    Exit for

End If

Next
***there are only 2 data values in excel file****
Reply
#4
Not Solved
go to File->Setting->run->Select one iteration only

try this it may solve your problem
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  FOR LOOP shayk1985 1 5,263 12-13-2012, 11:35 AM
Last Post: sams001
  How to exit from a for loop silpavinod 2 9,805 10-17-2012, 12:55 AM
Last Post: agarwl.anurag
  for loop sia sharma 1 3,324 09-13-2012, 11:44 AM
Last Post: ksrikanth2k9
  Help with Loop LJENNE 1 3,173 08-10-2012, 12:32 PM
Last Post: Ankesh
  Not able to Iterate using For Loop tanyamrz 2 3,341 05-22-2012, 09:41 PM
Last Post: tanyamrz

Forum Jump:


Users browsing this thread: 1 Guest(s)