SkiFreak Posted September 27, 2006 Share Posted September 27, 2006 I am checking to see if the contents in a file have changed by doing a line count of the file. This all works well (sort of) but I also wanted to include a tray icon to enable the user to close the monitoring application. Because I have a Sleep() in my loop, closing the application from the tray icon can take from 0 seconds to the maximum time of the Sleep(). Is there a better way to do this? While 1 $msg = TrayGetMsg() Select Case $msg = 0 $CheckLines = _FileCountLines($logFile) If $CountLines <> $CheckLines Then $LastLine = FileReadLine($logFile,$CountLines + 1) $array = stringsplit($LastLine,"|") MsgBox(48,$array[3] & " has reported the following problem:","Equipment: " & $array[1] & Chr(13) & _ "Fault: " & $array[2] & Chr(13) & _ "Computer: " & $array[4] & Chr(13) & _ "Time Reported: " & $array[6]) $CountLines = $CheckLines Else Sleep(10000) EndIf Case $msg = $exititem Exit EndSelect WEnd Link to comment Share on other sites More sharing options...
Helge Posted September 27, 2006 Share Posted September 27, 2006 Add the checking in a function and use it with AdlibEnable, where you specify that that it should call the function every 10000 msec. Link to comment Share on other sites More sharing options...
SkiFreak Posted September 28, 2006 Author Share Posted September 28, 2006 Add the checking in a function and use it with AdlibEnable, where youspecify that that it should call the function every 10000 msec.Excellent.Exactly what I was looking for. 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