Search the Community
Showing results for tags 'loop if'.
-
$oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 #include <MsgBoxConstants.au3> WinActivate("MyApplication") ;Make my application active Local $hWnd = WinWaitActive("MyApplication", "", 5) ;Waits for my application to be the active application $oExcel.Application.WorkBooks.Open("C:\Users\Charlie\Desktop\Data.xlsx") ;Opens an excel file local $iCell = $oExcel.Application.Cells(31,1).Value ;Reads the number from row 1, cell 31 of the open excel file If $hWnd Then For $a = 1 to $iCell Send("G*S/") Send($oExcel.Application.Cells($a,1).Value) Send("'SET/US") Sleep(1000) Send("{ENTER}") Sleep(2000) Send("MB") Send("{ENTER}") Sleep(2000) $file = @ScriptDir & "\DATA.log" $iNum = StringRegExp(FileRead($file), "(?sm).*^\h*(\d{1,3})", 1)[0] ;I am reading the last instance of 1-3 numeric values in the DATA.log file ConsoleWrite($iNum & @CRLF) ;;;This is what I want to add - I also want to read the second last line of the DATA.log file and keep looking for an error 'Invalid Request' ;;;If I find the error 'Invalid Request' then I go back to the start - If $hWnd Then ;;;If I do not find the error then proceed to the below steps If $hWnd Then For $i = 1 To $iNum Send("GSET"& $i &"/USR") Sleep(500) Send("{ENTER}") Sleep(1000) Next Else MsgBox(0, "", '"MyApplication" window not found.') EndIf Next EndIf $oExcel.Application.Quit In the above script, I want to add a condition after 'ConsoleWrite($iNum & @CRLF)'. If I find the text 'Invalid Request' in the second last line of the active DATA.log file then I go back to the start of the loop. However if I do not find the text 'Invalid Request' in the second last line of the Data.log file then i proceed to the further steps