http://sdkdocs.roku.com/display/sdkdoc/Event+Loops"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.