All pastes #947412 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-18 14:08 UTC
rendered paste body
; _ErrorCheckLog - Checks the last $numLines (int) lines of a log for occurances of $checkStr. If
; $checkStr occurs $max times, it returns True. Otherwise, it returns False.
; Requires: File.au3

Func _ErrorCheckLog($checkStr, $numLines, $max)
	$loglines = _FileCountLines($aolog)
	$count = 0

	If $loglines > $numLines+1 Then
		$loglines -= $numLines+1
		$logfile = FileOpen($aolog, 0)
		FileReadLine($logfile, $loglines)
		If @error = 0 Then
			For $i = 1 to $numLines
				If StringInStr(FileReadLine($logfile), $checkStr) Then
					$count += 1
				EndIf
			Next
		EndIf
		
		FileClose($logfile)
		
		If $count >= $max Then
			return True
		EndIf
	EndIf
	
	return False
EndFunc