Array of String Arrays

BlitzMax Forums/BlitzMax Programming/Array of String Arrays

Grey Alien(Posted 2007) [#1]
Had to figure this out earlier as the syntax is a little strange at first, some of you might find it useful:

Strict
Local test$[][5]

Local temp$[1]

temp[0] = "temp"

test[2] = temp

Print test[2][0]


I use string arrays all the time but that was the first time I made an ARRAY of string arrays. What was confusing me was that $[] is a type like String or Integer, but when I was declaring test with test$[][] I was thinking, hmm this is a 2D array and was treating it like such (and nothing compiled or if it did, it crashed).

It IS a 2D array really (sort of) but you can't treat it like one, see how I assign a string array called temp to slot 2 of test, yet if you think of test as a 2D array that shouldn't be possible because the first dimension was [] (i.e. unsized and thus not initialised) :-) Then when I print the first line of the attached string array I have to specify [2][0] where two is the main array slot and [0] is the first slot of the string array - this is counter-intuitive as when the array of string arrays was declared it looked like the dimensions were the other way round! Hope this makes sense for someone. I'm fine with it now.