Jump to content

restart script


PhilipG
 Share

Recommended Posts

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!

Link to comment
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
Link to comment
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.
Link to comment
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?

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...