2D arrays

Anyone know of a solution for storing multi-dimensional arrays? I want to store an array within another array. I was looking at the 2D Array library, however, it looks like all the nested arrays are required to be the same size.
Other options that to look at are Files, JSON, and Dictionaries libraries would work, however, requires additional work to convert are required: Array → Files/JSON/Dictionaries → Back to Array for Hamilton use. I am wondering if there is a more straight forward/elegant way to do this without having to jump through additional translations.

@chips-a-hoai - For multi-array style data structures, your above summary more-or-less captures your options in VENUS.

I don’t know if I am spoiling a secret here, but there is actually no such thing as a 2D array in VENUS. The 2D array library of HSL extensions instantiates a standard static array whose size is dictated by x ‘rows’ by y ‘columns’. So if you wanted 3 rows by 10 columns, all it does is generate an array of 30 elements. This is why that library requires the ‘arrays’ to be of conserved size (which isn’t always convenient).The library functions just provide convenience for managing the indexing when storing and getting values out of the array.

In order to store multi-array style data, you will need to program a couple extra intermediate style processing steps as you alluded to. One of the options I have gravitated to over the years when I need to process higher level data structures are dictionaries, which you have mentioned. In VENUS dictionaries are convenient as they support various variant types (int, flt, str etc) without having to be converted.

Another technique I have used in VENUS is to collapse an array of elements into a delimited string (via ‘JoinWithDelimiter’ of the HSLExtensions String library) which can then be managed as a single array element in an ‘array of arrays’, where the array of arrays is simply an array of delimited strings (where each element can maintain the data of an array of any size). To convert the delimited string elements back into an array format for further processing, you simply use the ‘Split’ function of the HSLExtensions String library. This is especially convenient when processing strings, but if not, you will need to convert variable types to and from strings.

Often times I have mixed the above technique with dictionaries in order to achieve complex data structure processing. The tradeoff is that you can dynamically dictate and process any schema you want, but will require you to do additional programming.



Thanks Nick,
For the collapsing method, is there a string size/length limitation? This can get a little out of hand if there’s tons of data.

1 Like

That is a great question. I actually don’t know as I have never hit the limit before.

Let me ask internally and run a couple of tests to see what info I can dig up.


1 Like

I will report back if I get any specific info, but I ran a quick test to build the most unwieldly arrays that I could, consisting of thousands of elements containing massive strings in the millions of characters.

My PC ran out of memory before I was able to get it to error due to character limitations. I would imagine that you are good.



Time to upgrade that computer memory :). Thanks for your help