Jump to content

Constantly changing GUI Output


Recommended Posts

Hi Jos, I tried yours but it jumps throught the script, flashes up the box and then quits..

Looks like your logic has a flaw. You are comparing the Control handle with a result and My guess is you always want to do the _FileListToArray .

Something like this maybe:

[/font]
While 1
    $FileList = _FileListToArray($filefolder, $fileextension);only list files with given extension
    If $FileList <> $lastlabel Then
        GUICtrlSetData($Label, "Jobs:   " & $FileList[0])
        $lastlabel = $FileList
        If $FileList = 0 Then
            GUICtrlSetData($Label, "Jobs: Null")
            ContinueLoop
        EndIf
    EndIf
WEnd

Link to comment
Share on other sites

You still have the _FileListToArray inside the IF which means it will never be executed after $I equals $LastI.

Check the modifications I made.

Ignore my last reply - I did not have the variable set - it's working now with yours but still with the flickering. The flicking is driving me nuts and when it returns a value of 0 the script just quits. I'm close of giving up. Don't understand why something so simple is so fricking complicated. It's a simple case of outputting a fricking number to a bloody GUI why does it constantly flicker ?

Link to comment
Share on other sites

  • Developers

Try this one to see if that works.

#include<file.au3>
$filefolder = 'd:temp'
$fileextension = '*.eml'
Global $Label = 0, $lastlabel = ""
$Gui = GUICreate("Web-DMZ Count", 200, 50)
GUISetBkColor(0xFFFF00)
GUISetState()
$Label = GUICtrlCreateLabel("Jobs:  0", 20, 20)

While 1
    $FileList = _FileListToArray($filefolder, $fileextension);only list files with given extension
    If $FileList <> 0 Then
        If $FileList[0] <> $lastlabel Then
            GUICtrlSetData($Label, "Jobs:    " & $FileList[0])
            $lastlabel = $FileList[0]
        EndIf
    Else
        If $lastlabel <> 0 Then
            GUICtrlSetData($Label, "Jobs: Null   ")
            $lastlabel = 0
        EndIf
    EndIf
WEnd

EDIT: Fixed some code logic

Edited by Jos
Fixed some code

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Made some logic changes in the previous code as the other version was also flawed ...(Haven't practice enough lately)

We should be getting closer now ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

That works a treat Jos, can you explain to me why this is no longer flickering [ is it because it will only update if there is a change ] and where I went wrong in regards to the $lastlabel ? Is this where the update is being controlled from ?

Try this one to see if that works.

#include<file.au3>
$filefolder = 'd:temp'
$fileextension = '*.eml'
Global $Label = 0, $lastlabel = ""
$Gui = GUICreate("Web-DMZ Count", 200, 50)
GUISetBkColor(0xFFFF00)
GUISetState()
$Label = GUICtrlCreateLabel("Jobs:  0", 20, 20)

While 1
    $FileList = _FileListToArray($filefolder, $fileextension);only list files with given extension
    If $FileList <> 0 Then
        If $FileList[0] <> $lastlabel Then
            GUICtrlSetData($Label, "Jobs:   " & $FileList[0])
            $lastlabel = $FileList[0]
        EndIf
    Else
        If $lastlabel <> 0 Then
            GUICtrlSetData($Label, "Jobs: Null   ")
            $lastlabel = 0
        EndIf
    EndIf
WEnd

EDIT: Fixed some code logic

Link to comment
Share on other sites

  • Developers

Correct, ... here is a version with a brief explanation:

While 1
    $FileList = _FileListToArray($filefolder, $fileextension) ;only list files with given extension
    ; Check if Files were found
    If $FileList <> 0 Then
        ; When files are found, check if the number of files changed
        If $FileList[0] <> $lastlabel Then
            ;Update the CONTROL in the GUI and save the new value when different
            GUICtrlSetData($Label, "Jobs:   " & $FileList[0])
            $lastlabel = $FileList[0]
        EndIf
    Else
        ; When NO files are found, check if the number of files isn'r 0 yet.
        If $lastlabel <> 0 Then
            ;Update the CONTROL in the GUI and save the new value when different
            GUICtrlSetData($Label, "Jobs: Null   ")
            $lastlabel = 0
        EndIf
    EndIf
WEnd

Problem was that previously we also referred to $FileList[0] when the _FileListToArray() returned 0 (No array) causing an error in the script.

That is now fixed with this version.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...