Jump to content

Best way to manage some variables...


Go to solution Solved by Melba23,

Recommended Posts

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?

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Moderators
  • Solution

misioooo,

 

ConsoleWrite and _ArrayDisplays shows empty array

of 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...