dwaynek Posted April 11, 2007 Share Posted April 11, 2007 is there a way to reference a variable name via a variable? eg i want to create a bunch of radio buttons but instead of doing : $radio1 = GUICtrlCreateRadio ("this is radio1", 10, 10) for each radio button... i want to do something like: $i=0 $top=10 while $i < 10 $i=$i+1 $radioname = "$radio" & $i MsgBox(0, "", $radioname) $radioname = GUICtrlCreateRadio ($avArray[$i-1], 10, $top) $top=$top+20 WEnd but the problem is when i get to: Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED it reports that $radio1 is not a defined variable. any ideas? Link to comment Share on other sites More sharing options...
EndFunc Posted April 11, 2007 Share Posted April 11, 2007 (edited) Take a look at this thread.http://www.autoitscript.com/forum/index.ph...st&p=314341 Edited April 11, 2007 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
martin Posted April 11, 2007 Share Posted April 11, 2007 is there a way to reference a variable name via a variable? eg i want to create a bunch of radio buttons but instead of doing : $radio1 = GUICtrlCreateRadio ("this is radio1", 10, 10) for each radio button... i want to do something like: $i=0 $top=10 while $i < 10 $i=$i+1 $radioname = "$radio" & $i MsgBox(0, "", $radioname) $radioname = GUICtrlCreateRadio ($avArray[$i-1], 10, $top) $top=$top+20 WEnd but the problem is when i get to: Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED it reports that $radio1 is not a defined variable. any ideas? This line $radioname = "$radio" & $i sets $radioname to have the value $radio1 if $i is 1 etc. It doesn't change the variable name. When you later say $radioname = GUICtrlCreateRadio ($avArray[$i-1], 10, $top) then $radioname now has the value which represents the radio button and no longer the value $radio1. What you need, and what might not be obvious from the link EndFunc gave you, is an array. Hers's how you code could be changed to use an an array of radio buttons. Dim $radioButton[10]; assume we want no more than 10 of them $i=0 $top=10 while $i < 10 MsgBox(0, "", "$radioButton[" & $i & "]" $radioButton[$i] = GUICtrlCreateRadio ($avArray[$i-1], 10, $top) $top=$top+20 $i=$i+1;<--- I moved this line to the end of the loop WEnd ;Then there should be no problem when you get to Case BitAND(GUICtrlRead($radioButton[1]), $GUI_CHECKED) = $GUI_CHECKED Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
dwaynek Posted April 11, 2007 Author Share Posted April 11, 2007 this is awesome! exactly what i needed. 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