Sign in to follow this  
Followers 0
PhilipG

restart script

8 posts in this topic

First of all, this is my first script. I have been doing some basic php and mysql earlier but never basic based stuff(apart from that).

My problem:

I have a GUI script. Everything works well.

I also have a function that will change all information in all labels in the whole script.

My question:

Is it possible some how the tell the script to "restart" or "reload" the labels but with some new variables? I've already tried a while loop, both with GUIsetdata and looping the whole script. But that made all labels flashing like crazy.

I don't even know if this is the best solution.

Would be very happy for any help!

Share this post


Link to post
Share on other sites



I guess what you want to do is to update the text displayed in a label

You should update it only when needed, not on each main loop...

update the label only if the text has to be changed

and, maybe, only once every so many milliseconds (100 ms in this example)

AutoItSetOption("MustDeclareVars", 1)

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $id_label, $myvar, $msg, $timer, $nowdiff, $lastupdatediff
    Const $ms_update_interval = 100

    GUICreate("My GUI")
    $id_label = GUICtrlCreateLabel("text", 10, 10, 100, 20)
    GUISetState()

    $timer = TimerInit()
    $lastupdatediff = 0

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop

        $nowdiff = TimerDiff($timer)
        $myvar = Int($nowdiff / 1000) & "s"
        If ($nowdiff - $lastupdatediff >= $ms_update_interval) Then
            If Not(GUICtrlRead($id_label) == $myvar) Then GUICtrlSetData($id_label, $myvar)
            $lastupdatediff = $nowdiff
        EndIf
    WEnd
EndFunc

Share this post


Link to post
Share on other sites

First of all, this is my first script. I have been doing some basic php and mysql earlier but never basic based stuff(apart from that).

My problem:

I have a GUI script. Everything works well.

I also have a function that will change all information in all labels in the whole script.

My question:

Is it possible some how the tell the script to "restart" or "reload" the labels but with some new variables? I've already tried a while loop, both with GUIsetdata and looping the whole script. But that made all labels flashing like crazy.

I don't even know if this is the best solution.

Would be very happy for any help!

Yeah, you definitely don't want to put them in a loop. It will keep doing that over and over. Only change the label when it's needed. You can always make the variable = something else after an action is done or an event happens then update your label data with GuiCtrlSetData().

If you need more help post some of your code, someone will help you.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Use function...

_resetLabel() ; first time set

While 1 ; main loop
    ; 
    If AnyChangeInVars Then _resetLabel() ; reset
WEnd
    
Func _resetLabel()
    ;
EndFunc

Hi ;)

Share this post


Link to post
Share on other sites

I've now written a update function that updates all fields affected. But this lead me to an other problem my updatescript looks like this (part of it, IRL there are more fields to update.:

func update($i)
    Local $Query, $Row, $iRows, $iColumns
    $Query = "SELECT * FROM uppdrag WHERE id=" & $i & " limit 1;";kollar uppdragets id
    _SQLite_GetTable ($dbn, $Query, $Row, $iRows, $iColumns); lagrar uppdragets id i $row['id']
    
    $updateradio= "$radio" & $Row['typ']; Puts together the variable name for the actual controlID
    
    GUICtrlSetData ($idinfo, $Row['id'])
    GUICtrlSetData ($uppdrag, $Row['uppdrag'])
        GUICtrlSetData ($kontaktperson, $Row['kontaktperson'])
    GUICtrlSetData ($tel1, $Row['tel1'])
    GUICtrlSetData ($tel2, $Row['tel2'])
    GUICtrlSetData ($till, $Row['till'])
    GUICtrlSetData ($deltagare, $Row['deltagare'])
    GUICtrlSetState ( eval($updateradio), $GUI_CHECKED)


    EndFunc

I think there is something wrong with the multidimensional arrays that should provide the new field values. (I've been working with mysql earlier so it is possibble that i've done something that doesn't work i SQLite

Also i'm not sure that the eval thing will work.

Any one that knows why?

Share this post


Link to post
Share on other sites

Since this is a new problem I've decided to start a new topic.

Thanks för the help on the first prob.

Share this post


Link to post
Share on other sites

Might want to check-out "Autoit Wrappers" it has some great scriplets to help YOUR script

8)


NEWHeader1.png

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