Sign in to follow this  
Followers 0
Styler001

Problem updating changed variables in a GUI

4 posts in this topic

This is my first time working with GUIs, so I'm not sure how to get to where I want to finish with this.

When the GUI starts, it reads an included file that contains some variables. One of the variables is $MinorHealKey. The value of this variable determines which button will initially be checked. If the variable is 1, button 1 is checked. If it's 2, button 2 is checked, etc. If it's 9, "not used" is checked. This part all works fine. If I do a GuiCtrlGetState at this point, I get the result I'm looking for.

My problem is that while I'm in the GUI, I could select a different button for MinorHealKey and when I exit the GUI, I want to save this new value to the variable in a new variable file that will be written to. With my code as it is below, is there any way to determine (at the time I choose to exit) what the changed value is?

I don't know if I'm being clear. Basically, the GUI loads the #include file which has $MinorHealKey = 3 and checks the appropriate button (Skill 3 in this case). During the course of using the GUI, I change MinorHealKey to 5. When I exit, I want $MinorHealKey = 5 written to the #include file. I know how to go about writing the file. I just don't know how to determine what the new value of MinorHealKey is. The code below just sets the state of the right button. I can't actually check the state until much later down in the code.

Can what I'm asking be done? Or is there a better way to go about it?

GUICtrlCreateGroup ("Minor Heal", 255, 60, 100, 217)

Dim $TopCoordArray = _ArrayCreate (90, 110, 130, 150, 170, 190, 210, 230, 250)
For $Count = 1 To 9
    If $Count = 9 Then
        $MinorHealRadio = GUICtrlCreateRadio ("Not Used", 260, $TopCoordArray[$Count - 1], 80, 20)
        If $Count = 9 And $MinorHealKey = 0 Then
            GUICtrlSetState (-1, $GUI_CHECKED)
        EndIf
    Else
        $MinorHealRadio = GUICtrlCreateRadio ("Skill " & $Count, 260, $TopCoordArray[$Count - 1], 80, 20)
    EndIf
    If $Count = $MinorHealKey Then
        GUICtrlSetState (-1, $GUI_CHECKED)
    EndIf
Next

Share this post


Link to post
Share on other sites



I wouldnt' suggest re-writing the include file if you are ever going to compile this, instead maybe look at the IniRead/Write functions, and put the new found variable values there. And read them at start up to get those values as well as Write to them on exit with the new values.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

What would be the downside to rewriting the included file if I compile the main script? On my long, ugly version of this one I did compile it and didn't notice any adverse effects. But then, I'm a noob at this, so there's still alot I don't understand yet.

And thanks. I'll give the IniRead/Write a look at.

But, I guess my question still is..........in my code above, since there isn't any one specific MinorHealRadio variable (such as $MinorHealRadio1, $MinorHealRadio2, etc.) assigned to each radio button, how do I determine, when I exit the script, which radio button is checked if I have made changes? As I had originally written this before I understood a little more and started paring it down, I did have separate variables for each button. That made it easy to determine which was checked. But it also made for an extremely long script since I have about 8 of these groups altogether.

Share this post


Link to post
Share on other sites

Well, I got it figured out. Here's the new code:

GUICtrlCreateGroup ("Minor Heal", 255, 60, 100, 217)
Dim $MinorHealRadioArray = _ArrayCreate (1, 2, 3, 4, 5, 6, 7, 8, 0)
Dim $TopCoordArray = _ArrayCreate (90, 110, 130, 150, 170, 190, 210, 230, 250)
For $ArrayCount = 0 To 8
    If $ArrayCount = 8 Then
        $MinorHealRadioArray[$ArrayCount] = GUICtrlCreateRadio ("Not Used", 260, $TopCoordArray[$ArrayCount], 80, 20)
        If $ArrayCount = 8 And $MinorHealKey = 0 Then
            GUICtrlSetState (-1, $GUI_CHECKED)
        EndIf
    Else
        $MinorHealRadioArray[$ArrayCount] = GUICtrlCreateRadio ("Skill " & $ArrayCount + 1, 260, $TopCoordArray[$ArrayCount], 80, 20)
    EndIf
    If $ArrayCount + 1 = $MinorHealKey Then
        GUICtrlSetState (-1, $GUI_CHECKED)
    EndIf
Next
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

I don't know if there's a cleaner way to do it, but that works.

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