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

Data structures question

I want to store tracks (url's of media items), track info (data about those media items) and posteritems in a single data structure that can be returned from a function.

I was thinking something like this:

return {TrackInfo:Trackobj,PosterItms:PosterObj,songURls:SongObj} 'roAssociativeArray

which would be returned to a function called from a loop:

dataobject=CreateObject("RoArray",1,true) 'should this be an RoArray or an RoAssociativeArray?
for each blah in xmltracklist
dataobject.push(getTracks(blah))
next


now how do I access the particular items from dataobject?

posterscreen.setContentList(dataobject.Posteritms)


Would that be the correct syntax?

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
1 REPLY 1
GandK-Geoff
Visitor

Re: Data structures question

"jbrave" wrote:
I was thinking something like this:

return {TrackInfo:Trackobj,PosterItms:PosterObj,songURls:SongObj} 'roAssociativeArray


This is fine (though you might consider a bit more whitespace 🙂 ).

"jbrave" wrote:
which would be returned to a function called from a loop:

dataobject=CreateObject("RoArray",1,true)[/color] [color=#BF0000]'should this be an RoArray or an RoAssociativeArray?
for each blah in xmltracklist
dataobject.push(getTracks(blah))
next


This is pretty close, though the first line can be much simplified:

dataobject = []


"jbrave" wrote:
now how do I access the particular items from dataobject?

posterscreen.setContentList(dataobject.Posteritms)


Would that be the correct syntax?


Close. Remember that dataobject is an array of associative arrays, so you have to pick an element:

posterscreen.setContentList(dataobject[current_track].Posteritms)


The variable name 'dataobject' is a bit confusing in this case. Perhaps 'track_info'?
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.