Though it’s true that multi-dimensional arrays are not
a “data type,” as Fenriswolf mentioned, you can access
a single dimensional array as a multi-dimensional easily with
script.
When I have done this, I define variables to represent
the number of rows and columns in the array.
myArray[10][20] has 10 rows and 20 columns.
So, I would do this:
var gRows = 10;
var gColumns = 20;
myArray[200];
To instantiate the array, you will need 2 loops,
an outer loop to step through each row, and an inner
loop to step through each column, using the gRows and
gColumns variables to control the number of iterations in each loop.
I like to use “set” and “get” functions to access the array,
this way I can sort of treat it like a multi-dimensional array
and can do custom “index out of range” error checking.
To set a value, I pass indexes just as if I were accessing
a multi-dimensional array.
myArray[4][18] = 10 becomes setArrayValue(4, 18, 10)
In the function I can test to see if a passed value is
“out of range” and then I can access the array position
like this:
myArray[(4*gRows)+18] = 10;
The “get” function does the same thing, except it is used to
get the value (I guess that was obvious
)
Doing this helps me to create a conceptual model, treating the single
dimensional array as a multi-dimensional one.
Rather than posting a bunch code on the forum, I have
created a .wdl that has all of the functions I mentioned.
You, or anyone else interested, can download it here:
http://www.ionstudios.net/arrayExample.zipHope this helps.