
squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2013
05:23 AM
No loop
Is there a way to get an Event, for instance an roAudioplayer status message without a message loop? Or to make a loop that loops once and exits?
I need to get the info at the start of a function, in the first couple of lines and have been unable to make a loop that doesn't take over and mess things up.
thanks
I need to get the info at the start of a function, in the first couple of lines and have been unable to make a loop that doesn't take over and mess things up.
thanks
Kinetics Screensavers
3 REPLIES 3
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2013
05:55 AM
Re: No loop
http://sdkdocs.roku.com/display/sdkdoc/Event+Loops
"end while"/"exit while" exits a message loop. So if you have this code -
and you change it to
Then when a button is pressed it will leave the loop.
"end while"/"exit while" exits a message loop. So if you have this code -
port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetMessagePort(port) ' instruct screen to send events to port
screen.Show()
while true
msg = wait(0, port) ' wait for a message
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed() then
return -1
elseif msg.isButtonPressed()
print "button pressed: ";msg.GetIndex()
else
' ignore other unknown or uninteresting roSpringBoardScreenEvents
endif
else
' ignore other events, not type roSpringboardScreenEvent
endif
end while
and you change it to
port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetMessagePort(port) ' instruct screen to send events to port
screen.Show()
while true
msg = wait(0, port) ' wait for a message
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed() then
return -1
elseif msg.isButtonPressed()
print "button pressed: ";msg.GetIndex()
EXIT WHILE
else
' ignore other unknown or uninteresting roSpringBoardScreenEvents
endif
else
' ignore other events, not type roSpringboardScreenEvent
endif
end while
Then when a button is pressed it will leave the loop.

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2013
06:25 AM
Re: No loop
Thank you destruk, those docs make a lot more sense after you explain something. I had tried the exit while , but i think i wasn't tying it to an event, i was just hoping it would exit on its own which it didn't seem to, or did but didn't exit properly. You really helped me out this morning, i appreciate it.
Kinetics Screensavers

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2013
10:27 AM
Re: No loop
Well in the end i got the same results as yesterday, that is any kind of loop, even the one you posted - prevents the springboard from reopening, and stops other things from working. Arrgg.
Kinetics Screensavers