misioooo Posted August 29, 2014 Posted August 29, 2014 Hello! What i want to do is: I have data that consists of: group number, sub-group number (many subgroups in each group), many variables in each subgroup (control IDs, data taken from combo boxes etc). I was struggling with 3d array to hold all this but... It isnt easy (at least for me) to track everything. My GUI allows to add/remove groups, subgroups etc. Is there a way to use some kind of object/structure for holding all the data? Something like: Object GROUP Object SUBGROUP1 data VAR1 data VAR2 data ctrlID1 data ctrlID2 ... Close SUBGROUP ... Object SUBGROUP n ... Close SUBGROUP n Close GROUP Which way would be best/easiest (in your opinion) to deal with that kind of data?
Moderators Melba23 Posted August 29, 2014 Moderators Posted August 29, 2014 misioooo,I would have a 2D array which covered the GROUPS & SUBGROUPS - each element of this array would then be a separate 1D array holding the data specific to that particular SUBGROUP. Now you only need to track the GROUP & SUBGROUP (2D so a much easier task) and then you can extract the internal SUBGROUP data array into a temporary array when you need to work on it (and that is only 1D). Please ask if you need any help in setting up such a structure. 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
JohnOne Posted August 29, 2014 Posted August 29, 2014 Or an SQLite database. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
misioooo Posted August 29, 2014 Author Posted August 29, 2014 No database available. So far i managed to create some functions that add/remove groups and subgroups... I have a problem with getting ControlID's into array and putting this "id" array into main data array (looks like the main array is empty): Func _AddGroup() ;resizing array $groups_subgroups[0] = $groups_subgroups[0]+1 ;adds additional group (counter) $groups_subgroups[1] = $groups_subgroups[1]+1 ;adds additional subgroup (counter) ReDim $data_all[$groups_subgroups[0]][$groups_subgroups[1]] ;resizing main data array ConsoleWrite("DEBUG - $data_all dimensions: "&UBound($data_all)&" : "&UBound($data_all,2)&@CRLF) ;adding new tab and controls GUICtrlCreateTabItem("Grupa "&$groups_subgroups[0]) $ids[$MANUFACTURER_LABEL] = GUICtrlCreateLabel("Producent",40,130,100) $ids[$MANUFACTURER] = GUICtrlCreateCombo("Samsung",40,150,100) $ids[$MODEL_LABEL] = GUICtrlCreateLabel("Model",150,130,150) $ids[$MODEL] = GUICtrlCreateCombo("",150,150,150) $ids[$NET] = GUICtrlCreateGroup("Podłączenie do sieci",260+50,130,150,40) $ids[$LAN] = GUICtrlCreateRadio("LAN",265+50,145) GUICtrlSetState(-1,$GUI_CHECKED) $ids[$GSM] = GUICtrlCreateRadio("GSM",315+50,145) $ids[$NET_NONE] = GUICtrlCreateRadio("Brak",365+50,145) GUICtrlCreateGroup("",-99,-99,1,1) ;end of radio buttons group $ids[$DISTANCE_LABEL] = GUICtrlCreateLabel("Odległość do poprzedniego monitora (m)",470,130) $ids[$DISTANCE] = GUICtrlCreateInput("5",540,150,50) $ids[$EXTENDER_LABEL] = GUICtrlCreateLabel("Wybierz extender",670,130) $ids[$EXTENDER] = GUICtrlCreateCombo("",670,150,150) GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateTabItem("") $data_all[UBound($data_all)-1][0] = $ids ;copies control IDs to main array in just created, new group ConsoleWrite("@DEBUG: "&$data_all[UBound($data_all)-1][0]) EndFunc I fill $ids with controlIDs. At the end i want to put this ids array into $data_all[last element][0]. ConsoleWrite and _ArrayDisplays shows empty array :/ What am i doing wrong?
Moderators Solution Melba23 Posted August 29, 2014 Moderators Solution Posted August 29, 2014 misioooo, ConsoleWrite and _ArrayDisplays shows empty arrayof course they will - they only show non-array elements. I am working on an improvement to _ArrayDisplay that will indicate when an array holds another array so that the element does not appear empty. This short snippet shows that the inner array really is there - and how to get at it:#include <Array.au3> ; Inner array Global $aInner[1] = ["Inner Element"] ; Outer array containing inner array Global $aOuter[1] = [$aInner] ;Is it really there? _ArrayDisplay($aOuter, "Appears empty!", Default, 8) ; Copy the inner array to show it is $aTmp = $aOuter[0] MsgBox($MB_SYSTEMMODAL, "But it is there!", $aTmp[0]) ; and you can get to it directly as well MsgBox($MB_SYSTEMMODAL, "And you can get to it directly!", ($aOuter[0])[0])All clear now? 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
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