
Multidimensional, multidimensional arrays
Imagine two, two-dimensional arrays, one placed into an element of the
other for easy hierarchical looping:
*CATEGORIES* | *ITEMS*
*What *placeholder | *what *color
Shirts {empty} | Button-Down Oxford Blue
| Polo Red
| Henley Gray
dim CatArray, ItemArray
redim CatArray(1, 0)
redim ItemArray(1, 2)
'--- somewhere in here all the values get assigned
ItemArray(0,0) = "Button-Down Oxford"
ItemArray(1,0) = "Blue"
'--- and so on...
CatArray(1,0) = ItemArray
var = CatArray(1,0)(1,1)
"var" now equals "red". In Visual Basic and VBScript, no problems.
Now, if I want to do this more than once, as in
*CATEGORIES* | *ITEMS*
*What *placeholder | *what *color
Shirts {blank} | Button-Down Oxford Blue
| Polo Red
| Henley Gray
Pants {empty} | Corduroy Black
| Twill OD Green
| Brushed Denim Indigo
I do this:
redim CatArray(1, 0)
redim ItemArray(1, 2)
'--- assign the first set of values
ItemArray(0,0) = "Button-Down Oxford"
'--- etc, etc, etc
CatArray(1,0) = ItemArray
'--- reset the item array for the next set of values
itemArray = ""
redim ItemArray(1, 2)
'--- assign the second set of values
ItemArray(0,0) = "Corduroy"
'--- etc, etc, etc
CatArray(1,1) = ItemArray
var = CatArray(1,1)(1,1)
In Visual Basic, "var" now equals "OD Green". In VBScript however,
the same code returns a "Type mismatch" error. Is there something I'm
overlooking, or is what I'm attempting not possible in VBScript?
Thanks!
Bill Morris
Seritas L.L.C.