zILikeAutoITz 0 Posted December 20, 2010 Hi AutoItscripter's, I have trouble with trying to write multiple variables to loop and use them. I have variables that contains "Control ID's" and send them with a function to destroy them. Please see the example. My english is bad command, sorry for that i try my best. I have make an example to make it more clear: #include <GUIConstantsEx.au3> guiMain() Func guiMain() GUICreate("", 200, 80) $g2d1 = GUICtrlCreateCheckbox("First choice", 10, 4) $g2d2 = GUICtrlCreateCheckbox("Second choice", 90, 4) $g2d3 = GUICtrlCreateLabel ("label1", 10, 30) $g2d4 = GUICtrlCreateLabel ("label2", 90, 30) $g2d5 = GUICtrlCreateButton("delete", 10, 50, 40, 18) GUISetState() ;Show GUI While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $g2d5 controlDestroy($g2d1, $g2d2, $g2d3, $g2d4, $g2d5) EndSelect WEnd EndFunc Func controlDestroy($g2d1, $g2d2, $g2d3, $g2d4, $g2d5) Local $g2d For $zcnt = 1 To 5 Step 1 GUICtrlDelete($g2d & $zcnt) ; somes are gone, i guess they are another id Next ;~ ConsoleWrite($g2d5) ;test EndFunc Yeah it's true if i can use arrays like $array[1]....$array[*n] than it's easy but i'm send them with a function. So i would to loop the "$g2d" and add the loop counter to him but can't get it to work like i think. Or may be it can't be done in this way that i'm thinking. >,< Any advice will be appreciate. Thank you. Share this post Link to post Share on other sites
Malkey 231 Posted December 20, 2010 Control IDs are numbered sequentially upon creation of the control. #include <GUIConstantsEx.au3> guiMain() Func guiMain() GUICreate("", 200, 80) $g2d1 = GUICtrlCreateCheckbox("First choice", 10, 4) $g2d2 = GUICtrlCreateCheckbox("Second choice", 90, 4) $g2d3 = GUICtrlCreateLabel("label1", 10, 30) $g2d4 = GUICtrlCreateLabel("label2", 90, 30) $g2d5 = GUICtrlCreateButton("delete", 10, 50, 40, 18) GUISetState() ;Show GUI While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $g2d5 controlDestroy($g2d1, $g2d5) EndSelect WEnd EndFunc ;==>guiMain Func controlDestroy($g2d1, $g2d5) Local $g2d For $zcnt = $g2d1 To $g2d5 GUICtrlDelete($zcnt) Next EndFunc ;==>controlDestroy Share this post Link to post Share on other sites
PsaltyDS 39 Posted December 20, 2010 You could use Eval() in a loop to get the value of multiple sequentially named variables. But using techniques like that means you have left sane coding practices far behind you. 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
zILikeAutoITz 0 Posted December 21, 2010 (edited) Woww, Thank you very much, Malkey. Hmm, it seems that it start from what i need to loop. I think i understand it more for now, about control id's like you sayed. Thank's !! Thank you for advice with the Eval() function i will give a try, this function seems very useful at the situtaion like this, thanks too !! I'm very appreciate. Edit: Added stuff. But using techniques like that means you have left sane coding practices far behind you.Does that mean i must do more practice? Sorry i'm try to understand u. So i have tried about the Eval() Func is think it's working, (for now) #include <GUIConstantsEx.au3> guiMain() Func guiMain() GUICreate("", 200, 80) $g2d1 = GUICtrlCreateCheckbox("First choice", 10, 4) $g2d2 = GUICtrlCreateCheckbox("Second choice", 90, 4) $g2d3 = GUICtrlCreateLabel ("label1", 10, 30) $g2d4 = GUICtrlCreateLabel ("label2", 90, 30) $g2d5 = GUICtrlCreateButton("delete", 10, 50, 40, 18) GUISetState() ;Show GUI While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $g2d5 controlDestroy($g2d1, $g2d2, $g2d3, $g2d4, $g2d5) EndSelect WEnd EndFunc Func controlDestroy($g2d1, $g2d2, $g2d3, $g2d4, $g2d5) Local $g2d For $zcnt = 1 To 5 Step 1 $g2d = Eval("g2d" & $zcnt) GUICtrlDelete($g2d) ConsoleWrite($g2d & @LF) ;test Next EndFunc Thank's Edited December 21, 2010 by zILikeAutoITz Share this post Link to post Share on other sites