roAssociativeArray dynamic tag selection?

If I have an associative array

}

I can easily retrieve any of the array members by key:

BrightScript Debugger> print categories.key1
test
west
best

is there any way to stick “key1” into a variable like;

keyvar=key1

print categories.keyvar

so I can call a function with the key as string and get back the member associated with that key?

in the meantime I’m using an if-then like this:

if key=“key1” : print categories.key1
if key=“key2” : print categories.key2
if key=“key3” : print categories.key3

and so on, but this presupposed that the key’s are known to the current function

You want the LookUp() ifAssociativeArray interface, as in:

print categories.LookUp("key1")

or

key="key1"
print categories.LookUp(key)

-JT

Thanks JT.

“renojim” wrote:
You want the LookUp() ifAssociativeArray interface, as in:

print categories.LookUp("key1")

or

key="key1"
print categories.LookUp(key)

-JT
Or the shorter version…

categories["key1"]