Sign in to follow this  
Followers 0
mike1305

variable within a varible's name?

31 posts in this topic

I have a GUI with 24 of these, all identical except for minor changes in X,Y coords and the names of the variables (replace the "1" with 1-24).

$program1_checkbox = GUICtrlCreateCheckbox($program1_name, 5, 30, 15, 15)
    If $program1_check = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
    If $program1_check = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)
    GUICtrlCreateLabel($program1_name, 25, 30, 125, 25)
    $program1_version = GUICtrlCreateInput($program1_version, 150, 25, 75, 25)
    $program1_path_button = GUICtrlCreateButton("Path", 230, 25, 50, 25)

the variable's definitions are farther up in the script.

is there a way to get around having 24x of these in the script and make it possible for, say:

$program(X)_checkbox= ....such and such...

and set it to to x = x + 1 until x = 24? I don't know the exact syntax of how this would work, but I could figure it out by studying it. The real question is can I put a variable within the variable itself.

If the answer is yes, I will pursue it farther, otherwise it was just a goofy idea. :P


Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites



from gafrost

#include <GuiConstants.au3>

Dim $Input_[41] ; creates an array

GUICreate("festlegen", 350, 490, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input = GUICtrlCreateInput("2", 40, 17, 20, 20)
$y = 70
For $x = 1 To 20 Step 2
    $Input_[$x] = GUICtrlCreateInput("edit" & $x, 20, $y, 140, 20)
    $Input_[$x + 1] = GUICtrlCreateInput("edit" & $x + 1, 20, $y + 20, 140, 20)
    $y = $y + 40
Next
GUICtrlSetData($Input_[20], "20")

$y = 70
For $x = 21 To 40 Step 2
    $Input_[$x] = GUICtrlCreateInput("Name" & $x, 190, $y, 140, 20)
    $Input_[$x + 1] = GUICtrlCreateInput("Name" & $x + 1, 190, $y + 20, 140, 20)
    $y = $y + 40
Next
GUICtrlSetData($Input_[40], "20")

$Group_41 = GUICtrlCreateGroup("EDITs", 10, 50, 160, 430)
$Group_42 = GUICtrlCreateGroup("Namen", 180, 50, 160, 430)
$Icon_43 = GUICtrlCreateIcon("icon.ico", 0, 10, 10, 32, 32)
$Label_44 = GUICtrlCreateLabel("Anzahl der EDITs (max. 20)", 65, 20, 140, 20)
$Button_45 = GUICtrlCreateButton("OK", 210, 10, 60, 30)
$Button_46 = GUICtrlCreateButton("Abbrechen", 280, 10, 60, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button_46
            Exit
        Case $msg = $Button_45
            $Check_input = GUICtrlRead($Input)
            If $Check_input >= 20 Then
                For $x = 1 To 40
                    If GUICtrlRead($Input_[$x]) >= 20 Then
                        GUICtrlSetState($Input_[$x], $GUI_DISABLE)
                    Else
                        GUICtrlSetState($Input_[$x], $GUI_ENABLE)
                    EndIf
                Next
            EndIf
    EndSelect
   
WEnd

hope that helps

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

EDIT...Beat me to it

Edited by kjmarket

Pink Floyd - The Wall

Share this post


Link to post
Share on other sites

Don't mean to look like an idiot, but I'm not quite sure how the script works. :P


Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

What is it supposed to do?


Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

You don't need a variable in a variable, what you are describing is an array. For example instead of:

$checkbox1

$checkbox2

$checkbox3

You could have:

$checkbox[0]

$checkbox[1]

$checkbox[2]

This would make it easier to access the values through a For loop instead of accessing each one seperatly.

Ex:

For $i = 0 to 2

$checkbox[$i]

Next

Share this post


Link to post
Share on other sites

I don't know squat about arrays. Time to hit the books, er, helpfile!

Thanks for the tips, info, and program!


Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

I don't know squat about arrays. Time to hit the books, er, helpfile!

Thanks for the tips, info, and program!

Been there :P !

Truly look at arrays until you feel you have a grasp on them, I have to say, they have made my life 10x's easier, and (100x's) less code then what I used to do.


[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

#9 ·  Posted (edited)

OK, arrays are still getting the best of me.

I am getting errors all over the place. thank god I backed up a version of the working one. :nuke:

Global $program
$program[1]="program1"
$program[2]="program2"
$program[3]="program3"
$program[4]="program4"
$program[5]="program5"
$program[6]="program6"
$program[7]="program7"
$program[8]="program8"
$program[9]="program9"
$program[10]="program10"
$program[11]="program11"
$program[12]="program12"
$program[13]="program13"
$program[14]="program14"
$program[15]="program15"
$program[16]="program16"
$program[17]="program17"
$program[18]="program18"
$program[19]="program19"
$program[20]="program20"
$program[21]="program21"
$program[22]="program22"
$program[23]="program23"
$program[24]="program24"
$program[25]="program25"
$program[26]="program26"
$program[27]="program27"
$program[28]="program28"
$program[29]="program30"
$program[31]="program31"
$program[32]="program32"

For $i = 1 to 32 Step 1
    Global $program_name[i] =    IniRead("settings.ini", $program[i], "name", "not found")
    Global $program_check[i] =   IniRead("settings.ini", $program[i], "check", "4")
    Global $program_version[i] = IniRead("settings.ini", $program[i], "version", "not found")
    Global $program_path[i] =    IniRead("settings.ini", $program[i], "path", "not found")
Next

there is a second part where I tried to make the GUI with the arrays but eh didnt work so well. The error I recieve:

C:\Scripts\arraytest.au3(35,24) : ERROR: syntax error
    Global $program_name[i]
    ~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3(36,25) : ERROR: syntax error
    Global $program_check[i]
    ~~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3(37,27) : ERROR: syntax error
    Global $program_version[i]
    ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3(38,24) : ERROR: syntax error
    Global $program_path[i]
    ~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3 - 4 error(s), 0 warning(s)

Any help? :P

I added the working, non-array script so you can get an idea of what's happening. it is about 50% functional (some of the path buttons dont work yet, and it isnt attached to the parent script yet)

the full script, as is w/o arrays, is looking to be 1500+ lines.

script.zip

Edited by mike1305

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I see alot of people reading this topic but no replies. Feel free to give me any advice you have, I need it. :nuke:

Also please download the ZIP. it helps one understand why I wish to use an array. :P

Edited by mike1305

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

You are using i instead of $i in your loop.

try

For $i = 1 to 32 Step 1
    Global $program_name[$i] =    IniRead("settings.ini", $program[$i], "name", "not found")
    Global $program_check[$i] =   IniRead("settings.ini", $program[$i], "check", "4")
    Global $program_version[$i] = IniRead("settings.ini", $program[$i], "version", "not found")
    Global $program_path[$i] =    IniRead("settings.ini", $program[$i], "path", "not found")
Next
Edited by BPBNA

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You are using i instead of $i in your loop.

try

For $i = 1 to 32 Step 1
    Global $program_name[$i] =    IniRead("settings.ini", $program[$i], "name", "not found")
    Global $program_check[$i] =   IniRead("settings.ini", $program[$i], "check", "4")
    Global $program_version[$i] = IniRead("settings.ini", $program[$i], "version", "not found")
    Global $program_path[$i] =    IniRead("settings.ini", $program[$i], "path", "not found")
Next
I'm retarded. :">

new error.

C:\Scripts\arraytest.au3(35,32) : ERROR: syntax error
    Global $program_name[$i] =  IniRead
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3(36,32) : ERROR: syntax error
    Global $program_check[$i] =   IniRead
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3(37,32) : ERROR: syntax error
    Global $program_version[$i] = IniRead
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3(38,32) : ERROR: syntax error
    Global $program_path[$i] =  IniRead
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Scripts\arraytest.au3 - 4 error(s), 0 warning(s)
Edited by mike1305

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

Maybe something like this?

Global $program[33][4]

For $i = 1 to 32 Step 1
    $program[$i][0] =    IniRead("settings.ini", "program" & $i, "name", "not found")
    $program[$i][1] =    IniRead("settings.ini", "program" & $i, "check", "not found")
    $program[$i][2] =    IniRead("settings.ini", "program" & $i, "version", "not found")
    $program[$i][3] =    IniRead("settings.ini", "program" & $i, "path", "not found")
Next

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Nice add, bluebear. here is my script now, only one error remaining:

#include<GUIConstants.au3>

Global $program[33][4], $program_checkbox, $program_path_button

For $i = 1 to 32 Step 1
    $program[$i][0] =    IniRead("settings.ini", "program" & $i, "name", "not found")
    $program[$i][1] =    IniRead("settings.ini", "program" & $i, "check", "not found")
    $program[$i][2] =    IniRead("settings.ini", "program" & $i, "version", "not found")
    $program[$i][3] =    IniRead("settings.ini", "program" & $i, "path", "not found")
Next

;;;;;;;;;;

GUICreate("Change Latest Versions", 600, 600)
$checkbox_y = 30
$name_y = 25
$version_y = 150
$path_y = 230
For $i = 1 to 16
    $program_checkbox[$i] = GUICtrlCreateCheckbox($program[$i][0], 5, $checkbox_y, 15, 15)
    If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
    If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)
    $program[$i][0] = GUICtrlCreateInput($program[$i][0], 25, $name_y, 125, 25)
    $program[$i][2] = GUICtrlCreateInput($program[$i][1], 150, $version_y, 75, 25)
    $program_path_button[$i] = GUICtrlCreateButton("Path", 230, $path_y, 50, 25)
    $checkbox_y = $checkbox_y + 25
    $name_y = $name_y + 25
    $version_y = $version_y + 25
    $path_y = $path_y + 25
Next
GUISetState()

It doesn't like the variable $program_checkbox[$i] . Says it is a Badly formated variable or macro., kills it at the opening bracket before the $i. I am so close I can smell it! I put a semicolon in front of the checkbox and the path button (didnt like em for some reason) and added the While loop and the GUI popped up. got some of the math wrong but it isnt important.

thanks for all your patience so far! I plan to make this script into something that everyone can use. I know alot of AutoIt users are network admins trying to automate installs and network functions. this should be of help. :nuke:

So I guess the next step is to get the checkbox and path button to work. any clue as to why? it isn't inproperly formatted as far as I can tell, but what do I know I can't even type a variable correctly. :P


Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

This works, though not everything is lined up properly. Comments on the right show where I made changes.

#include<GUIConstants.au3>

Global $program[33][6], $program_checkbox, $program_path_button ; BB - added elements to the second dimension

For $i = 1 to 32 Step 1
    $program[$i][0] =    IniRead("settings.ini", "program" & $i, "name", "not found")
    $program[$i][1] =    IniRead("settings.ini", "program" & $i, "check", "not found")
    $program[$i][2] =    IniRead("settings.ini", "program" & $i, "version", "not found")
    $program[$i][3] =    IniRead("settings.ini", "program" & $i, "path", "not found")
Next

;;;;;;;;;;

GUICreate("Change Latest Versions", 600, 600)
$checkbox_y = 30
$name_y = 25
$version_y = 150
$path_y = 230
For $i = 1 to 16
    $program[$i][4] = GUICtrlCreateCheckbox($program[$i][0], 5, $checkbox_y, 15, 15) ; BB - modified variable
    If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
    If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)
    $program[$i][0] = GUICtrlCreateInput($program[$i][0], 25, $name_y, 125, 25)
    $program[$i][2] = GUICtrlCreateInput($program[$i][1], 150, $version_y, 75, 25)
    $program[$i][5] = GUICtrlCreateButton("Path", 230, $path_y, 50, 25) ; BB - modified variable
    $checkbox_y = $checkbox_y + 25
    $name_y = $name_y + 25
    $version_y = $version_y + 25
    $path_y = $path_y + 25
Next
GUISetState()
 
; BB - added the below just to show the GUI
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

This seems to line things up better:

#include<GUIConstants.au3>

Global $program[33][6], $program_checkbox, $program_path_button ; BB - added elements to the second dimension

For $i = 1 to 32 Step 1
    $program[$i][0] =    IniRead("settings.ini", "program" & $i, "name", "not found" & $i)
    $program[$i][1] =    IniRead("settings.ini", "program" & $i, "check", "not found"  & $i)
    $program[$i][2] =    IniRead("settings.ini", "program" & $i, "version", "not found"  & $i)
    $program[$i][3] =    IniRead("settings.ini", "program" & $i, "path", "not found" & $i)
Next

;;;;;;;;;;

GUICreate("Change Latest Versions", 600, 600)
$checkbox_y = 30
$name_y = 25
$version_y = 150
$path_y = 230
For $i = 1 to 16
    $program[$i][4] = GUICtrlCreateCheckbox($program[$i][0], 5, $checkbox_y, 15, 15) ; BB - modified variable
    If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
    If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)
    $program[$i][0] = GUICtrlCreateInput($program[$i][0], 25, $name_y, 125, 25)
    $program[$i][2] = GUICtrlCreateInput($program[$i][1], 150, $name_y, 75, 25)
    $program[$i][5] = GUICtrlCreateButton("Path", 230, $name_y, 50, 25) ; BB - modified variable
    $checkbox_y = $checkbox_y + 25
    $name_y = $name_y + 25
Next
GUISetState()
 
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Thank you soooooooooo much for the help! Arrays make alot more sense now. Holy crap, you helped me turn over 150 varaibles into one array. amazing!


Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I have one more issue. In my GUI, there are "Path" buttons that when clicked lead to a GUI that allows for user input to where the location of a program's EXE and installer are. I wish to utilize my newly found love for arrays in making the buttons work. When they are clicked, the only way that I know to make the corresponding window to show is by using GUIGetMsg() for that particular button, and then giving instructions on the window thereafter. BUT, it makes for 32 seperate ElseIf's in the While...WEnd loop. The problem is that the way it is set up, the Path window instantly pops up and I can't tell which one it's for. can you tell autoit to wait for a button to be clicked?

;;;;;;;;checks to make sure ini exists.;;;;;;;;;;;
    $settingsfilecheck = FileExists("settings.ini")
    If $settingsfilecheck = 0 Then
        MsgBox(0, "", "Unable to find settings.ini.")
        Exit
    EndIf
    
    
    Global $program[34][7], $program_checkbox, $program_path_button ; BB - added elements to the second dimension
    
    For $i = 1 to 32 Step 1
        $program[$i][0] =    IniRead("settings.ini", "program" & $i, "name", "not found" & $i)
        $program[$i][1] =    IniRead("settings.ini", "program" & $i, "check", "not found"  & $i)
        $program[$i][2] =    IniRead("settings.ini", "program" & $i, "version", "not found"  & $i)
        $program[$i][3] =    IniRead("settings.ini", "program" & $i, "path", "not found" & $i)
        $program[$i][4] =    IniRead("settings.ini", "program" & $i, "install", "not found" & $i)
    Next
    
    ;;;;;;;;;;
    
    GUICreate("Change Latest Versions", 600, 600)
    $checkbox_y = 30
    $name_y = 25
    
    For $i = 1 to 16
        $program[$i][6] = GUICtrlCreateCheckbox($program[$i][0], 5, $checkbox_y, 15, 15) ; BB - modified variable
        If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
        If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)
        $program[$i][0] = GUICtrlCreateInput($program[$i][0], 25, $name_y, 125, 25)
        $program[$i][2] = GUICtrlCreateInput($program[$i][2], 150, $name_y, 75, 25)
        $program[$i][5] = GUICtrlCreateButton("Path", 230, $name_y, 50, 25) ; BB - modified variable
        $checkbox_y = $checkbox_y + 25
        $name_y = $name_y + 25
    Next
    
    ;;;;;;;;;;
    
    $checkbox_y = 30
    $name_y = 25
    $version_y = 25
    $path_y = 25
    For $i = 17 to 32
        $program[$i][6] = GUICtrlCreateCheckbox($program[$i][0], 305, $checkbox_y, 15, 15)
        If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
        If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)
        $program[$i][0] = GUICtrlCreateInput($program[$i][0], 325,  $name_y, 125, 25)
        $program[$i][2] = GUICtrlCreateInput($program[$i][2], 450,  $version_y, 75, 25)
        $program[$i][5] = GUICtrlCreateButton("Path", 530, $path_y, 50, 25)
        $checkbox_y = $checkbox_y + 25
        $name_y = $name_y + 25
        $version_y = $version_y + 25
        $path_y = $path_y + 25
    Next
    
    $save = GUICtrlCreateButton("Save Changes", 25, 550, 100, 25)
    $cancel = GUICtrlCreateButton("Cancel Changes", 150, 550, 100, 25)
    GUICtrlCreateLabel("Standard Programs", 100, 5, 150, 15)
    GUICtrlCreateLabel("Instructions:", 20, 430, 60, 25)
    GUICtrlCreateLabel("Checked boxes mean that the program next to it will be scanned for." &    _
            "  Uncheck the box if you wish to not scan for it.  Changes will be " &    _
            "saved until you come back and undo them in this same window.  If you " &    _
            "wish to permanently delete a custom entry, check the appropriate boxes " &    _
            "and select 'delete checked programs' (highly unreccomended).  When " &    _
            "changing a version, make sure to use the syntax X.X.X.X as shown already.  " &    _
            "If version is not important and you wish to simply check for existance, " &    _
            "type 'exist' into the version box.  NOTE:  all changes to 'path' are " &  _
            "immediate and do not require the 'save' button be pressed.", 20, 450, 560, 85)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            Exit
        ElseIf $msg = $save Then
            Exit
        ElseIf $msg = $cancel Then
            Exit
;;;;;;;;;;;;LOOK HERE FOR MY PROBLEM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ElseIf $msg = $program[$i][5] Then
            GUICreate("Locations", 400, 200)
            GUICtrlCreateLabel("Enter the location of the EXE file.", 20, 20, 360, 25)
            $program[$i][3]=GUICtrlCreateInput($program[$i][3],20, 30, 380, 25)
            $program[$i][4]=GUICtrlCreateInput($program[$i][4], 20, 60, 380, 25)
            GUISetState()
            While 1
                $msg = GUIGetMsg()
                If $msg = $GUI_EVENT_CLOSE Then 
                    GUIDelete()
                    ExitLoop
                EndIf
            WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        EndIf
    WEnd
Edited by mike1305

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I have one more issue. In my GUI, there are "Path" buttons that when clicked lead to a GUI that allows for user input to where the location of a program's EXE and installer are. I wish to utilize my newly found love for arrays in making the buttons work. When they are clicked, the only way that I know to make the corresponding window to show is by using GUIGetMsg() for that particular button, and then giving instructions on the window thereafter. BUT, it makes for 32 seperate ElseIf's in the While...WEnd loop. The problem is that the way it is set up, the Path window instantly pops up and I can't tell which one it's for. can you tell autoit to wait for a button to be clicked?

CODE
;;;;;;;;checks to make sure ini exists.;;;;;;;;;;;

$settingsfilecheck = FileExists("settings.ini")

If $settingsfilecheck = 0 Then

MsgBox(0, "", "Unable to find settings.ini.")

Exit

EndIf

Global $program[34][7], $program_checkbox, $program_path_button ; BB - added elements to the second dimension

For $i = 1 to 32 Step 1

$program[$i][0] = IniRead("settings.ini", "program" & $i, "name", "not found" & $i)

$program[$i][1] = IniRead("settings.ini", "program" & $i, "check", "not found" & $i)

$program[$i][2] = IniRead("settings.ini", "program" & $i, "version", "not found" & $i)

$program[$i][3] = IniRead("settings.ini", "program" & $i, "path", "not found" & $i)

$program[$i][4] = IniRead("settings.ini", "program" & $i, "install", "not found" & $i)

Next

;;;;;;;;;;

GUICreate("Change Latest Versions", 600, 600)

$checkbox_y = 30

$name_y = 25

For $i = 1 to 16

$program[$i][6] = GUICtrlCreateCheckbox($program[$i][0], 5, $checkbox_y, 15, 15) ; BB - modified variable

If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)

If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)

$program[$i][0] = GUICtrlCreateInput($program[$i][0], 25, $name_y, 125, 25)

$program[$i][2] = GUICtrlCreateInput($program[$i][2], 150, $name_y, 75, 25)

$program[$i][5] = GUICtrlCreateButton("Path", 230, $name_y, 50, 25) ; BB - modified variable

$checkbox_y = $checkbox_y + 25

$name_y = $name_y + 25

Next

;;;;;;;;;;

$checkbox_y = 30

$name_y = 25

$version_y = 25

$path_y = 25

For $i = 17 to 32

$program[$i][6] = GUICtrlCreateCheckbox($program[$i][0], 305, $checkbox_y, 15, 15)

If $program[$i][1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)

If $program[$i][1] = 0 Then GUICtrlSetState(-1, $GUI_UNCHECKED)

$program[$i][0] = GUICtrlCreateInput($program[$i][0], 325, $name_y, 125, 25)

$program[$i][2] = GUICtrlCreateInput($program[$i][2], 450, $version_y, 75, 25)

$program[$i][5] = GUICtrlCreateButton("Path", 530, $path_y, 50, 25)

$checkbox_y = $checkbox_y + 25

$name_y = $name_y + 25

$version_y = $version_y + 25

$path_y = $path_y + 25

Next

$save = GUICtrlCreateButton("Save Changes", 25, 550, 100, 25)

$cancel = GUICtrlCreateButton("Cancel Changes", 150, 550, 100, 25)

GUICtrlCreateLabel("Standard Programs", 100, 5, 150, 15)

GUICtrlCreateLabel("Instructions:", 20, 430, 60, 25)

GUICtrlCreateLabel("Checked boxes mean that the program next to it will be scanned for." & _

" Uncheck the box if you wish to not scan for it. Changes will be " & _

"saved until you come back and undo them in this same window. If you " & _

"wish to permanently delete a custom entry, check the appropriate boxes " & _

"and select 'delete checked programs' (highly unreccomended). When " & _

"changing a version, make sure to use the syntax X.X.X.X as shown already. " & _

"If version is not important and you wish to simply check for existance, " & _

"type 'exist' into the version box. NOTE: all changes to 'path' are " & _

"immediate and do not require the 'save' button be pressed.", 20, 450, 560, 85)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

Exit

ElseIf $msg = $save Then

Exit

ElseIf $msg = $cancel Then

Exit

;;;;;;;;;;;;LOOK HERE FOR MY PROBLEM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ElseIf $msg = $program[$i][5] Then

GUICreate("Locations", 400, 200)

GUICtrlCreateLabel("Enter the location of the EXE file.", 20, 20, 360, 25)

$program[$i][3]=GUICtrlCreateInput($program[$i][3],20, 30, 380, 25)

$program[$i][4]=GUICtrlCreateInput($program[$i][4], 20, 60, 380, 25)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

GUIDelete()

ExitLoop

EndIf

WEnd

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;

EndIf

WEnd

Save yourself a lot of trouble and take the time to learn to use Opt("GuiOnEventMode", 1). You can eliminate the GuiGetMsg() part and just attach a function to the event you are interested in. For example, to exit when the gui is closed:

#include <GuiConstants.au3>
Opt("GuiOnEventMode", 1)
$hMainGui = GUICreate("Change Latest Versions", 600, 600) ; save the GUI's handle to a variable!
GuiSetOnEvent($GUI_EVENT_CLOSE, "_Quit", $hMainGui)
While 1
    Sleep(100)
Wend

Func _Quit()
    Exit
EndFunc

This really is the easier way in the long run... :P

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for the tip. I will test it out and let you know tomorrow if it solves my problem with the path button. :P

If anything it saves me lines of script. the only problem is that I already have the while loops made so it would be more work to go back and fix them. :nuke:


Amp Energy Drink: the official sponsor of me scripting at 2AM.

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