maxcronjob Posted October 7, 2005 Share Posted October 7, 2005 Okay, I created a monster script that does a lot of testing and prints out lines to a log file. The log file has a number of PASS and FAIL entries in it. What I need to do is come up with a way to count all the PASS and all the FAIL entries and spit them out at the END of that logfile... I'm wondering if there's a way to do this outside the script rather than going back in and adjusting each PASS and FAIL to increase in count after they've printed out to the log file, then print out the number of counts for each in the end. Any suggestions? thanks, max Link to comment Share on other sites More sharing options...
Skruge Posted October 7, 2005 Share Posted October 7, 2005 _FileReadToArray() would be a good start. Loop through the array and use StringSplit() if there are multiple entries per line. Increment your counters whenever you find a match. p.s. Doing this within the monster script would be much quicker. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
GaryFrost Posted October 8, 2005 Share Posted October 8, 2005 (edited) #include <file.au3> Dim $aRecords, $search = "Line3" If Not _FileReadToArray(@ScriptDir & "\test.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf $y = 1 $occurance = 0 For $x = 1 to $aRecords[0] while 1 if StringInStr($aRecords[$x],$search,0,$y) Then $occurance = $occurance + 1 $y = $y + 1 Else $y = 1 ExitLoop EndIf WEnd Next Msgbox(0,'found word (' & $search & ')',$occurance & " times.") Edited October 8, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
maxcronjob Posted October 25, 2005 Author Share Posted October 25, 2005 #include <file.au3> Dim $aRecords, $search = "Line3" If Not _FileReadToArray(@ScriptDir & "\test.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf $y = 1 $occurance = 0 For $x = 1 to $aRecords[0] while 1 if StringInStr($aRecords[$x],$search,0,$y) Then $occurance = $occurance + 1 $y = $y + 1 Else $y = 1 ExitLoop EndIf WEnd Next Msgbox(0,'found word (' & $search & ')',$occurance & " times.") AWESOME! I tweaked it and got it to work! PERFECT!!!! THANKS!!!!!!max Link to comment Share on other sites More sharing options...
GaryFrost Posted October 25, 2005 Share Posted October 25, 2005 yw, didn't even remember this thread. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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