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

“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 :slightly_smiling_face: ).

“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’?