Sign in to follow this  
Followers 0
Cusem

Array like variables possible?

2 posts in this topic

#1 ·  Posted (edited)

I have this routine:

If $tablename[1] = "" Then
    GUICtrlSetState($chk_tbl1, $GUI_DISABLE)
Else
    GUICtrlSetState($chk_tbl1, $GUI_ENABLE)
EndIf

However, I need to repeat this routine 16 times for table 1 to table 16, so is there a way to tidy up the code instead of copy/pasting the code above?

Something like (which doesnt work, but to give an example):

For $a = 1 to 16
        If $tablename[$a] = "" Then
            GUICtrlSetState($chk_tbl&$a, $GUI_DISABLE)
        Else
            GUICtrlSetState($chk_tbl&$a, $GUI_ENABLE)
        EndIf
    Next

EDIT:

Ok...I am stupid.

I just figured out it's actually possible to use arrays with guicommands

Example:

Dim $chk_tbl[3]

$chk_tbl[1] = GuiCtrlCreateCheckBox(" ", etc...

$chk_tbl[2] = GuiCtrlCreateCheckBox(" ", etc...

Didn't know this, but now I do!

Edited by Cusem

Share this post


Link to post
Share on other sites



Can't you just store the handle of the control in the same array and make it multi dimensional?

Like..

Dim $tablename[17][2]
$tablename[0][0] = 16;Total number of controls.
$tablename[1][0] = GUICtrlCreate....;First handle goes here.
$tablename[1][1] = "....";First string value goes here.
$tablename[$n][0] =;$nth handle goes here.
$tablename[$n][1] =;$nth string value goes here.
;Repeat it for all your controls.

For $a = 1 to $tablename[0][0]
     If $tablename[$a][1] = "" Then
          GUICtrlSetState($tablename[$a][0] $GUI_DISABLE)
     Else
          GUICtrlSetState($tablename[$a][0], $GUI_ENABLE)
     EndIf
Next

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