Jump to content

Looking for a better solution


Recommended Posts

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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...