Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jbrave
Channel Surfer

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
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
3 REPLIES 3
renojim
Community Streaming Expert

Re: roAssociativeArray dynamic tag selection?

You want the LookUp() ifAssociativeArray interface, as in:
print categories.LookUp("key1")
or
key="key1"
print categories.LookUp(key)

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
jbrave
Channel Surfer

Re: roAssociativeArray dynamic tag selection?

Thanks JT.
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: roAssociativeArray dynamic tag selection?

"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"]
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.