Starfighter Posted July 3, 2007 Posted July 3, 2007 Dear Autoit-Freaks I made a long Code: Func IFSetData() GUICtrlSetData($ListViewItem_A1,Chr(124) & $V_1) GUICtrlSetData($ListViewItem_A2,Chr(124) & $V_2) GUICtrlSetData($ListViewItem_A3,Chr(124) & $V_3) GUICtrlSetData($ListViewItem_A4,Chr(124) & $V_4) GUICtrlSetData($ListViewItem_A5,Chr(124) & $V_5) GUICtrlSetData($ListViewItem_A6,Chr(124) & $V_6) GUICtrlSetData($ListViewItem_A7,Chr(124) & $V_7) GUICtrlSetData($ListViewItem_A8,Chr(124) & $V_8) GUICtrlSetData($ListViewItem_A9,Chr(124) & $V_9) GUICtrlSetData($ListViewItem_A10,Chr(124) & $V_10) End Func This code does work. Then I made a shorter Code: Func IFSetData() For i$=1 to 10 GUICtrlSetData($ListViewItem_A & i$,Chr(124) & $V_ & i$) Next End Func This code doesn't work. What's wrong with this shorter code? Please, help me. I'm a newbie.
cshorey Posted July 3, 2007 Posted July 3, 2007 (edited) Taking a quick look your variable i has a typo. Func IFSetData() For $i=1 to 10 GUICtrlSetData($ListViewItem_A & $i,Chr(124) & $V_ & $i) Next End Func as far as appending you commands like that I don't know if you can or can't do it that way. chris Edited July 3, 2007 by cshorey ...
Josbe Posted July 3, 2007 Posted July 3, 2007 Try:GUICtrlSetData(Eval("ListViewItem_A" & $i), Chr(124) & Eval("V_" & $i))Read about: Eval() AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
Starfighter Posted July 4, 2007 Author Posted July 4, 2007 Try: GUICtrlSetData(Eval("ListViewItem_A" & $i), Chr(124) & Eval("V_" & $i)) Read about: Eval() I'm glad. Very thank you much!
Starfighter Posted July 4, 2007 Author Posted July 4, 2007 Sorry, I have a problem with an another code: Long code: _GUICtrlComboResetContent($ComboBoxControlGenre_1) _GUICtrlComboResetContent($ComboBoxControlGenre_2) _GUICtrlComboResetContent($ComboBoxControlGenre_3) _GUICtrlComboResetContent($ComboBoxControlGenre_4) _GUICtrlComboResetContent($ComboBoxControlGenre_5) _GUICtrlComboResetContent($ComboBoxControlGenre_6) _GUICtrlComboResetContent($ComboBoxControlGenre_7) _GUICtrlComboResetContent($ComboBoxControlGenre_8) _GUICtrlComboResetContent($ComboBoxControlGenre_9) _GUICtrlComboResetContent($ComboBoxControlGenre_10) This code does work. Shorter code: For $i=1 to 10 _GUICtrlComboResetContent(Eval("$ComboBoxControlGenre_" & $i)) Next This code doesn't work! I'm very confuse
PsaltyDS Posted July 4, 2007 Posted July 4, 2007 Sorry, I have a problem with an another code: Long code: _GUICtrlComboResetContent($ComboBoxControlGenre_1) _GUICtrlComboResetContent($ComboBoxControlGenre_2) _GUICtrlComboResetContent($ComboBoxControlGenre_3) _GUICtrlComboResetContent($ComboBoxControlGenre_4) _GUICtrlComboResetContent($ComboBoxControlGenre_5) _GUICtrlComboResetContent($ComboBoxControlGenre_6) _GUICtrlComboResetContent($ComboBoxControlGenre_7) _GUICtrlComboResetContent($ComboBoxControlGenre_8) _GUICtrlComboResetContent($ComboBoxControlGenre_9) _GUICtrlComboResetContent($ComboBoxControlGenre_10) This code does work. Shorter code: For $i=1 to 10 _GUICtrlComboResetContent(Eval("$ComboBoxControlGenre_" & $i)) Next This code doesn't work! I'm very confuse Your first Yoga chant: "Assign/Eval are evil... assign/eval are evil... assign/eval are evil..." Now some code: #include <guiconstants.au3> #include <guicombo.au3> Opt("GuiOnEventMode", 1) ; Arrays are zero-based, but you numbered from 1 so we create the array with 11 vice 10, and ignore [0] Dim $avComboBoxes[11] GUICreate("ComboBoxes", 200, 350) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") For $n = 1 To 10 $avComboBoxes[$n] = GUICtrlCreateCombo("Combo: " & $n, 10, ($n * 30) - 20, 180, 20) Next GUICtrlCreateButton("Reset", 50, 310, 100, 30) GUICtrlSetOnEvent(-1, "_Reset") GUISetState() While 1 Sleep(20) WEnd Func _Quit() Exit EndFunc ;==>_Quit Func _Reset() For $n = 1 To 10 _GUICtrlComboResetContent($avComboBoxes[$n]) Next EndFunc ;==>_Reset Notice how easily the control IDs are stored when creating the GUI, and referenced in the _Reset() function. Now for your second level mantra: "Arrays are our friends... arrays are our friends... arrays are our friends..." 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
Starfighter Posted July 4, 2007 Author Posted July 4, 2007 Don't use $ in Eval.Now, this code does work:For $i=1 to 10_GUICtrlComboResetContent(Eval("ComboBoxControlGenre_" & $i))NextThank you very much.
Josbe Posted July 4, 2007 Posted July 4, 2007 Take note about the PsaltyDS advice and the docs. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
PsaltyDS Posted July 4, 2007 Posted July 4, 2007 Now, this code does work:For $i=1 to 10_GUICtrlComboResetContent(Eval("ComboBoxControlGenre_" & $i))NextThank you very much.Use the arrays, Starfighter! Don't give in to the Dark Side!Assign leads to Eval.Eval leads to GOTO.GOTO leads to suffering... 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
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