JohnOne Posted February 8, 2010 Share Posted February 8, 2010 (edited) Ive been trying to create a gui using an array and a counter. The results I get are not expected by me, so I must be doing something wrong. The simple gui will have 20 lables named 0-19, That works fine. I expected the Array colums to contain the same data, 0 - 19, Wrong it contains 3 - 23 I cannot figure out why, but my guess is Im using ByRef incorrectly. Any pointers to my problem, and/or bad habits in my code would be welcomed please. #include <Array.au3> #include <Guiconstants.au3> Global $aGuiData[20] Func _GuiCreate(ByRef $aGuiData) $Gui = GUICreate("Test",400,400,500,100) Local $a = 0 For $i = 5 To 290 Step 15 $aGuiData[$a] = GUICtrlCreateLabel($a,5,$i,390,20) $a += 1 Next GUISetState() EndFunc _GuiCreate($aGuiData) _ArrayDisplay($aGuiData) while 1 Sleep(50) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect Wend Edited February 8, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2010 Moderators Share Posted February 8, 2010 JohnOne,You are setting the array elements to the ControlIDs of the labels. There are the internal numbers which AutoIt uses to keep track of the controls it creates. For reasons too complicated to go into here, these start at 3 - hence your array starts from 3.These ControlIDs are what Autoit looks for in a GUIGetMsg loop and what you use to identify controls in many AutoIt commands.Questions? 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 Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2010 Author Share Posted February 8, 2010 (edited) Thanks for the explaination Melba23, I had in in my head that they would just be 0 to 19 as displayed in the _ArrayDisplay(). I was looking for a minimalistic way to assign $variables to the control IDs for later use, without typing them all out. Got My eye wiped eh. Thanks again Mate. Edit: what threw me was first I was using a MsgBox() to display $aGuiData[19], and its output was what I expected .. 19. (after having read the label I mean) wierd. Edited February 8, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 9, 2010 Moderators Share Posted February 9, 2010 JohnOne,No, it is not wierd - it is exactly what should happen! Think about it - you have set the [19] element of the array to the ControlID of the 19th label. So when you useGUICtrlRead($aArray[19])you are reading the control whose ControlID is in the [19] element - which is the 19th label. It matters little to you that the actual value of the [19] element is 22 (or whatever!). This is the clever bit about using the ControlIDs - as long as you know the variables in which you have stored them, the actual values are transparent to the user.I hope that explains it better - do ask if not. That is why we are here after all! 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 Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2010 Author Share Posted February 9, 2010 Yep, I think I get it. Although I wish I had'nt used arrydisplay for testing now, cause its just something else Im thinking about while figuring out my script. Appreciate the help mucker, you're like a knight in shining armour. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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