aghering Posted February 11, 2015 Posted February 11, 2015 Hello, I have question on how to use GUICtrlSetData in a Do.. Until.. Loop. Local $a= 0, $b= 1, $c= 2 Do GUICtrlSetData('lab_SItemAmount'& $b, $SCA_LeftRow[$a]) GUICtrlSetData('$lab_SItemAmount'& $c, $SCA_RightRow[$a]) $a= $a + 1 $b= $b + 2 $c= $c + 2 Until $a= 5 In the above code, i got the value's i need in array's and i am trying to set the value to labels on my GUI. My labels are named "$lab_SItemAmount1.2.3...10", with even numbers on the right side and uneven numbers on the left side. The problem i am facing is that cannot seem to call my labels variable in the way i'm using above, i have tried many different ways with no luck. Any suggestions?
Moderators Solution Melba23 Posted February 11, 2015 Moderators Solution Posted February 11, 2015 aghering,Either use Eval to get each label ControlID when required or, much better, store the label ControlIDs in an array and loop through them. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kylomas Posted February 11, 2015 Posted February 11, 2015 Also, check out GuiCtrlSetData in the Help file. The first parm is a control ID... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
aghering Posted February 11, 2015 Author Posted February 11, 2015 Thank you for taking the time to answer my question. I was looking for the "Eval" command in the autoit help file but with no references to Eval on the "GuiCtrlSetData" page and looking for Control ID gives to many hits, is kinda difficult to find your result. Its good to know about the existence of "Eval" but i think i am going for your suggestion on storing the Control ID in a Array. I tested at work with a quick and dirty script and works nice. Question is Answered! I got a question on the side: my programming skill are getting better lately and focusing much more in making a efficient/clean code; is there a away to make this loop more efficient and less static?
Moderators Melba23 Posted February 11, 2015 Moderators Posted February 11, 2015 aghering, I was looking for the "Eval" command in the autoit help fileObviously not very hard - Eval. But using arrays is by far the best way. As to streamlining, why not use an algorithm to determine the other 2 variables? This seems functionally identical:Local $a= 0, $b= 1, $c= 2 Do ConsoleWrite($a & " - " & $b & " - " & $c & @CRLF) $a= $a + 1 $b= $b + 2 $c= $c + 2 Until $a= 5 ConsoleWrite(@CRLF) For $i = 0 To 4 ; Derive the other variables from the first ConsoleWrite($i & " - " & (2 * $i) + 1 & " - " & (2 * $i) + 2 & @CRLF) NextAny use? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kylomas Posted February 11, 2015 Posted February 11, 2015 is there a away to make this loop more efficient and less static? Can you define this a little more clearly? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
kylomas Posted February 11, 2015 Posted February 11, 2015 aghering, Here is a couple of way that static labels might be created and populated... expandcollapse popup#include <GUIConstantsEx.au3> #AutoIt3Wrapper_Add_Constants=n example1() example2() func example1() local $aCTLD[10] local $gui010 = guicreate('GuiCtrlSetData Example', 370,300) $aCTLD[0] = guictrlcreatelabel('',50,10,100,20) $aCTLD[1] = guictrlcreatelabel('',50,30,100,20) $aCTLD[2] = guictrlcreatelabel('',50,50,100,20) $aCTLD[3] = guictrlcreatelabel('',50,70,100,20) $aCTLD[4] = guictrlcreatelabel('',50,90,100,20) $aCTLD[5] = guictrlcreatelabel('',220,10,100,20) $aCTLD[6] = guictrlcreatelabel('',220,30,100,20) $aCTLD[7] = guictrlcreatelabel('',220,50,100,20) $aCTLD[8] = guictrlcreatelabel('',220,70,100,20) $aCTLD[9] = guictrlcreatelabel('',220,90,100,20) for $1 = 0 to ubound($aCTLD) - 1 guictrlsetdata($aCTLD[$1], 'Static Label # ' & stringformat('%03i', $1 + 1)) next guisetstate() while 1 switch guigetmsg() case $gui_event_close guidelete($gui010) return EndSwitch WEnd endfunc func example2() local $aCTLD[10] local $gui010 = guicreate('GuiCtrlSetData Example', 400,300) local $idx = 0 for $1 = 1 to 2 for $2 = 1 to 5 $aCTLD[$idx] = guictrlcreatelabel('',$1 * 100, $2 * 30 + 10, 50, 20) $idx += 1 next next for $1 = 0 to ubound($aCTLD) - 1 guictrlsetdata($aCTLD[$1], stringformat('%03i', $1 + 1)) next guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd endfunc Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
aghering Posted February 12, 2015 Author Posted February 12, 2015 (edited) The examples you guys gave me looks good and going to use them as a reference, I got the Array part worked out (initial question) and i will have a look at the method how bohica worked out the guictrlcreatelabel. Thanks again for your input! Edited February 12, 2015 by aghering
kylomas Posted February 12, 2015 Posted February 12, 2015 Good, glad it helped...any questions just ask... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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