Sign in to follow this  
Followers 0
SkiFreak

Looking for a better solution

3 posts in this topic

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

Share this post


Link to post
Share on other sites



Add the checking in a function and use it with AdlibEnable, where you

specify that that it should call the function every 10000 msec.

Share this post


Link to post
Share on other sites

Add the checking in a function and use it with AdlibEnable, where you

specify that that it should call the function every 10000 msec.

Excellent.

Exactly what I was looking for. :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0