ericnail Posted December 28, 2010 Share Posted December 28, 2010 I am trying to figure out ways to label/declare/read variables without using their "$Name" handles. For instance: I know you can read a variable like so: $check1 = GUICtrlCreateCheckbox("1",15, $const_top) $check2 = GUICtrlCreateCheckbox("2",50, $const_top) $check3 = GUICtrlCreateCheckbox("3",85, $const_top) $check4 = GUICtrlCreateCheckbox("4",120, $const_top) For $i = 1 to 4 Step 1 MsgBox(1, "", "The value of Checkbox " & $i & " is " & Eval("check"$i) & "." & @CRLF & "Note: 4 = Unchecked, 1 = Checked") Next This will of course create a Message Box of each checkbox's state/numeral. I also know that you can label variables like so: $Var1 = 0 $Var2 = 0 $Var3 = 0 $Var4 = 0 For $i = 1 to 4 Step 1 Assign("Var"&$i, $i) Next And this will lable each variable with it's number. However, I can't seem to find other ways to do things such as this. For instance, what about Setting the State, or disabling, etc.? I've tried both For $i = 1 to 4 Step 1 Assign("check"&$i, $GUI_CHECKED, 2) Next and For $i = 1 to 4 Step 1 Assign("check"&$i, $GUI_UNCHECKED, 2) Next and although this SHOULD set the states by setting the variables to said state numbers (1 being checked and 4 being unchecked), it doesn't. I've tried the Assign() function with a couple other situations and still no. So are there any other ways that I dont know about besides the Assign() & Eval() functions, or is there a special way to make it work, or is there simply no way to do special operations with string defined variables? Thanks in Advance! All the best, Eric Link to comment Share on other sites More sharing options...
trancexx Posted December 28, 2010 Share Posted December 28, 2010 That works just fine for me. Better (and usual) would be to use array. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Werty Posted December 28, 2010 Share Posted December 28, 2010 GUICtrlSetState() ? Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Malkey Posted December 28, 2010 Share Posted December 28, 2010 To read and set a check box use GUICtrlRead() and GUICtrlSetState(). - refer help file. 99.9 times out of 100 I would use an array to store the check box control id's - Local $check[4] This example only exists for its novelty aspects. Global Const $GUI_CHECKED = 1 ; From #include <GUIConstantsEx.au3> Global Const $GUI_UNCHECKED = 4 ; From #include <GUIConstantsEx.au3> ; ($GUI_SHOW is 16 + $GUI_ENABLE is 64) = 80 ; From #include <GUIConstantsEx.au3> Example() Func Example() Local $msg, $const_Left = 20 GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered For $i = 1 To 4 Assign("check" & $i, GUICtrlCreateCheckbox("CheckBox " & $i, $const_Left, 15 + ($i - 1) * 20)) Next GUISetState() ; will display an dialog box with 1 checkbox For $i = 1 To 4 GUICtrlSetState(Execute("$check" & $i), $GUI_CHECKED) ; Check checkbox MsgBox(0, "What's happening.", "The control id of Checkbox " & $i & " is " & Eval("check" & $i) & " (sequencially increasing)." & @CRLF & _ "The value of Checkbox " & $i & " is " & GUICtrlRead(Eval("Check" & $i)) & " ($GUI_CHECKED = 1)." & @CRLF & _ "The label of Checkbox " & $i & ' is "' & GUICtrlRead(Eval("Check" & $i), 1) & '"' & @CRLF & _ ; Advanced optiomal parameter = 1 "Note: Checkbox " & $i & " is Checked.") GUICtrlSetState(Eval("check" & $i), $GUI_UNCHECKED) ; Uncheck checkbox Next ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = -3 Then ExitLoop ; $GUI_EVENT_CLOSE = -3 ; From #include <GUIConstantsEx.au3> WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now