How to store/reference a group of arrays?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

How to store/reference a group of arrays?

Post by PuzzledGreatly » 19 Mar 2023, 02:28

I have a set of folder paths and a set of file names both in drop down menus. When a path is matched with a file the path is searched according to the contents of the file and three arrays are created. What is the best approach for linking this information together? Currently if a new file/path combination is selected the arrays are discarded. If a path file combination is re-selected I'm recreating the arrays from scratch. I think it would be more efficient to store the arrays. I thought of using an associative array with the path and file name as the key but how to link the three arrays to that key? Could I have an object (is that the right term?) array and store the three arrays in the object array and use that as the value for the key? Is there a better approach? Is there a recommended approach for this kind of one to many problem? Thanks

User avatar
Chunjee
Posts: 1421
Joined: 18 Apr 2014, 19:05
Contact:

Re: How to store/reference a group of arrays?

Post by Chunjee » 19 Mar 2023, 19:41

If your data is split among three arrays, I imagine it like this:
image.png
image.png (10.89 KiB) Viewed 226 times


What I often do is create an array of objects, some people call it a table:
image.png
image.png (14.99 KiB) Viewed 226 times

User avatar
Chunjee
Posts: 1421
Joined: 18 Apr 2014, 19:05
Contact:

Re: How to store/reference a group of arrays?

Post by Chunjee » 19 Mar 2023, 19:45

If your file contents cannot comfortably be in the larger object. Perhaps reference them via key:

image.png
image.png (25.33 KiB) Viewed 226 times

User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: How to store/reference a group of arrays?

Post by PuzzledGreatly » 20 Mar 2023, 19:40

Thanks very much for the replies. I think an array of objects is what I need.

Post Reply

Return to “Ask for Help (v1)”