I’m just playing with multidimensional dictionaries in TBX. For example:
var:dictionary myParameters;
myParameters["par1"] = "the 1st value";
myParameters["par2"] = 2;
myParameters["par3"] = "the 3rd value";
myParameters["par4"] = "key 1 (L2):value 1;key 2 (L2):value 2;key 3 (L2):key 1 (L3):value 1";
testDicts(myParameters);
and a primitive function to access the dicts on each level:
function testDicts(theParameters:dictionary) {
var:string singleValue;
var:dictionary singleDictionary;
if(!theParameters.empty){
theParameters.keys.each(singleKey){
singleValue = theParameters[singleKey];
if(singleValue.contains(":")) {
singleDictionary = dictionary(singleValue);
testDicts(singleDictionary);
} else {
doDebugLog_db("Key: " + singleKey + " = " + singleValue);
}
};
};
};
this will return (doDebugLog_db just passes the string to $Text of a note):
Key: par2 = 2
Key: par3 = the 3rd value
Key: key 1 (L3) = value 1
Key: key 1 (L2) = value 1
Key: par1 = the 1st value
Key: key 2 (L2) = value 2
My questions are:
- is there a better way to deal with multidimensional dictionaries in TBX?
- why are the elements get processed in this order?
Thanks a lot!