BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2012
04:45 AM
Dynamic category list for SimplePoster SDK example
I want to create a category list that is populated based on the folder names on an external drive. I'm still new to BrightScript so even though this should be easy i'm having a bit of trouble understanding how to do this. Am i waaay off based on the code shown below?
With those lines of code the program does not even run but does not produce a compile error when loading it to the Roku.
Function getCategoryList() As Object
list = m.filesystem.getdirectorylisting("ext1:/")
cl = createobject("roArray",list.count(),true)
for each folder in list
cl.push(folder)
end for
categoryList = cl
return categoryList
End Function
With those lines of code the program does not even run but does not produce a compile error when loading it to the Roku.
11 REPLIES 11
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2012
01:02 PM
Re: Dynamic category list for SimplePoster SDK example
Without commenting on any specifics of your code, I would offer the following advice: print is your best friend when you're trying to figure out what's going on. For example, you say the code doesn't even run. What is that based on? I'd add some prints, like:
print list, print folder, etc.
-JT
print list, print folder, etc.
-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.
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.
BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2012
05:19 PM
Re: Dynamic category list for SimplePoster SDK example
Thanks for the tip. I was trying to do it blinded without using Print calls. :oops: Turns out i didn't set up the roFileSystem to have a message port. It is now showing categories based on the names of folders on the external drive.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2012
05:31 PM
Re: Dynamic category list for SimplePoster SDK example
"BinaryMadman" wrote:
Thanks for the tip. I was trying to do it blinded without using Print calls. :oops: Turns out i didn't set up the roFileSystem to have a message port. It is now showing categories based on the names of folders on the external drive.
roFileSystem doesn't require a message port, and there's nothing in the code you posted above that would require a message port. It sounds like there was probably something else going on that you fixed inadvertently.
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2012
09:32 PM
Re: Dynamic category list for SimplePoster SDK example
That is probably the case. The only thing i changed was adding two lines of code:
I'll see later if taking out the setmessageport does anything.
m.filesystem = CreateObject("roFilesystem")
m.filesystem.SetMessagePort(m.port)
I'll see later if taking out the setmessageport does anything.
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2012
10:08 PM
Re: Dynamic category list for SimplePoster SDK example
You wouldn't be able to use the filesystem if you didn't have an object reference to it. So no, the messageport wouldn't change anything in this case. 🙂
BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2012
01:59 AM
Re: Dynamic category list for SimplePoster SDK example
"destruk" wrote:
You wouldn't be able to use the filesystem if you didn't have an object reference to it. So no, the messageport wouldn't change anything in this case. 🙂
Haha. I'm still very new to this so i'm learning as i go along.
Not sure if i should start a new topic or just put this here since i already have two topics out there and i don't want to fill the board with my noob questions but:
How do i traverse through an array of associative arrays (Content Meta-Data)? I think know i use Screen.GetContentList() and assign it to a variable to get them but what is the syntax for accessing a specific array and a specific associative array?
I understand if the mods split this into another thread.
MSGreg
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2012
06:33 AM
Accessing arrays of associative arrays
"BinaryMadman" wrote:
How do i traverse through an array of associative arrays (Content Meta-Data)? I think know i use Screen.GetContentList() and assign it to a variable to get them but what is the syntax for accessing a specific array and a specific associative array?
I understand if the mods split this into another thread.
I would vote for new thread for each question. Or at least change the subject 🙂
; Typed from memory. Sorry for any syntax errors.
; Access arrays with an integer index
; access associative arrays with string index when using a variable as the key or dot formation if you already know they key
; Variable access to associative array within an array
for index = 0 to array.Count()-1
for each key in array[index]
print "array[" ; index ; "][" ; key ; "] = "; array[index][key]
end for
end for
; Keep in mind that many content meta-data elements are themselves arrays or associative arrays, which you'll need to add another level of access.
; Here's an example of accessing an associative array within an array where you know the key
for index = 0 to array.Count()-1
print array[index].Title; " "; array[index].Url;
end for
The roArray implements the ifArray interface and the ifArrayGet interface (among others). roArray also implements ifEnum interface, so it can be used in a for each loop just like the roAssociativeArray.
Use a foreach loop for an associative array. The loop variable is the associative array key. If you want to access the key outside of a foreach loop, try using the ifEnum interface on the roAssociativeArray object.
BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2012
11:39 AM
Re: Dynamic category list for SimplePoster SDK example
The syntax was accurate, didn't get stuck anywhere. I was able to use a slightly modified version of your code. Thank you!
jlfreund
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2012
03:28 PM
Re: Dynamic category list for SimplePoster SDK example
This was something that was confusing to me in the documentation.
roImageCanvas takes in an roAssociativeArray describing the text and images to layout, but the documentation for roAssociativeArray just describes methods to manage key-value pairs in a single structure, leading me wonder how to dynamically construct an roAssociativeArray with an array of structures. The BrightScript reference doesn't mention it, but the post (Sun Sep 09, 2012 5:33 am) above seems to indicate that roAssociativeArray also apparently supports the ifArray interface? The sample code in that message doesn't mention it, but I assume it's sending "Count()" to an roAssociativeArray? Or should it be possible for roImageCanvas SetLayer to take in an roArray of roAssociativeArrays?
roImageCanvas takes in an roAssociativeArray describing the text and images to layout, but the documentation for roAssociativeArray just describes methods to manage key-value pairs in a single structure, leading me wonder how to dynamically construct an roAssociativeArray with an array of structures. The BrightScript reference doesn't mention it, but the post (Sun Sep 09, 2012 5:33 am) above seems to indicate that roAssociativeArray also apparently supports the ifArray interface? The sample code in that message doesn't mention it, but I assume it's sending "Count()" to an roAssociativeArray? Or should it be possible for roImageCanvas SetLayer to take in an roArray of roAssociativeArrays?