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?

2

1 Answer 1

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")
Sign up to request clarification or add additional context in comments.

1 Comment

Thank You, that's what I'll go with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.