Mallikarjun Posted November 21, 2011 Share Posted November 21, 2011 Hi,I am searching some text in the file that file is continuously updating(log file) ..if text not found in the file..it means it has to wait for some time and recheck the text 3 times...if found than exit the script...Is their any solution for this..Reply should be appreciate..ThanksMallikarjun QuoteMultiQuoteEdit Link to comment Share on other sites More sharing options...
kylomas Posted November 21, 2011 Share Posted November 21, 2011 Mallikarjun, Yes, there is a solution for this...where is your code? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted November 21, 2011 Share Posted November 21, 2011 (edited) There is solution. Edited November 21, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted November 21, 2011 Share Posted November 21, 2011 (edited) for $x=1 to 3 Sleep(100) function() next RTFM Edited November 21, 2011 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Tonnie Posted November 22, 2011 Share Posted November 22, 2011 I would start with something like this:$WaitTime = 60000 $StringToFind = "test" $LogFileFullPath = "C:Templogfile.txt" While 1 If _FindInFile($StringToFind, $LogFileFullPath) Then ExitLoop Sleep($WaitTime) WEnd(Note that this only checks once every time, not three times.)For the _FindInFile function, maybe take a look at an example script by guinness: Link to comment Share on other sites More sharing options...
pieeater Posted November 23, 2011 Share Posted November 23, 2011 (edited) here is an example which reads the file in question until the string your looking for is found. it is only meant as a demonstration to learn from so don't just add it to your script and expect it to work. the way i tested it was using another script i made which changed the value in a script faster than the script checking the value. here is my example: $j = 0 While 1 $bleh = bleh() ;call the function to check if the value is in the string ConsoleWrite($bleh & @CRLF) If $bleh == True Then ;if the file is in the string add 1 to the variable $j $j += 1 Else $j = 0 ;otherwise set it back to 0 EndIf If $j >=3 Then Exit ;once the string has been found 3 times exit the script Sleep(300) WEnd Exit;just in case exit is never a bad thing to have Func bleh() $var = FileRead(@ScriptDir & 'file1.txt');read the file If StringInStr($var, '1') Then;check if the file contains your string Return True;if yes, return true Else Return False;if no, return false EndIf EndFunc here is the other script to change the value in the file: HotKeySet("{esc}", "_exit");so all you have to do is press escape when you want it to stop While(1) Sleep(100) FileDelete(@ScriptDir & 'file1.txt') FileWrite(@ScriptDir & 'file1.txt', Random(0,1,1)) WEnd Func _exit() Exit EndFunc to test like i did put the 2 scripts in a empty folder and run the script changing the value and then run the other one through scite. Edited November 23, 2011 by pieeater [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
kylomas Posted November 23, 2011 Share Posted November 23, 2011 ...interesting that there have been 5 replies over several days without hearing froim the OP... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 23, 2011 Share Posted November 23, 2011 Maybe he's repeating his sleep function and hasn't woke up lol Personally, I'd rather think of a logical way to avoid looping with a sleep statement. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now