2

I am converting a php program over to VBScript for ASP. I am stuck trying to find a way to structure a multi-dimensional array and could use some help.

Here is how it sets up in the php version:

// $_SESSION[model name][level name][menu name] => [state]
$_SESSION[$model] = array('level_name' => array('menu_name' => array()));

and then here is how I set a value later on

$_SESSION[$model][$level_name][$menu_name] = array('menu_state' => 'UNCHECKED');

Here is what I tried in VBScript that doesn't work

Session(model).Add "level_name", Array()
Session(model)("level_name").Add "menu_name", Array()
Session(model)("level_name")("menu_name").Add "menu_state", Array()

and then try to set the value

Session(model)(level_name)(menu_name)("menu_state") = "UNCHECKED"

but I end up with the very helpful 500 Server Error.

Any ideas?

1 Answers1

1

You need a Dictionary of Dictionaries:

  Dim dicX : Set dicX = CreateObject("Scripting.Dictionary")
  Set dicX("A") = CreateObject("Scripting.Dictionary")
  Set dicX("A")("B") = CreateObject("Scripting.Dictionary")
  Set dicX("A")("B")("C") = CreateObject("Scripting.Dictionary")
  dicX("A")("B")("C")("D") = "WhatEver"
  WScript.Echo dicX("A")("B")("C")("D")
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96