Say I create some global map variable, potentially with nested maps like this example below. Would there be a way to retrieve the values from within the map variable in a standard function command?
function OnClick(clickData)
{
// Create empty map variables
var testOuterMap = DOpus.Create.Map();
var testInnerMap = DOpus.Create.OrderedMap();
// Set arbitrary value for key/value for inner map, then put inner map into outer map
testInnerMap.Set("WhateverKey", "Example String");
testOuterMap.Set("InnerMap", testInnerMap);
// Also create string key/value in outer map
testOuterMap.Set("SomeString", "Some Test String");
// Create testMapGlobal global variable using outer map
DOpus.vars.set("testMapGlobal", testOuterMap);
}
So the structure of the variable is basically:
testMapGlobal :
⤷ { SomeString : "Some Test String" }
⤷ InnerMap :
⤷ { WhateverKey : "Example String" }
To get the value back with jscript it would just be like this for example:
// ------ Test Retrieving value from global -----------
var retrievedOuterMap = DOpus.vars.get("testMapGlobal");
var retrievedInnerMap = retrievedOuterMap.Get("InnerMap");
var retrievedValue = retrievedInnerMap.Get("WhateverKey");
// Output value in a few possible ways
DOpus.Output(retrievedValue);
DOpus.Output(retrievedInnerMap.get("WhateverKey"));
DOpus.Output(retrievedInnerMap("WhateverKey"));
DOpus.Output(retrievedOuterMap("SomeString"));
I tried to do something like this in a user command but it doesn't work and I couldn't figure out if it's even retrieving the map as a map object:
@Set TestMap={$glob:testMapGlobal}
@Output Value Using Function1: {$TestMap("SomeString")}
@Output Value Using Evaluator1: {=$TestMap("SomeString")=}
@Output Value Using Function2: {$glob:testMapGlobal("SomeString")}
@Output Value Using Evaluator2: {=$glob:testMapGlobal("SomeString")=}
@Output Type Using Evaluator1: {=TypeOf($TestMap)=}
@Output Type Using Evaluator2: {=TypeOf($glob:testMapGlobal)=}