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: 
EngoTom
Visitor

Quick Brightscript questions

Question 1, How do I cast a string to an int?

if "1" > 2
'do something
end if


Question 2, how do I pass a reference to a variable?

From my poster screen I pass an roArray to the scringboard when I create it. If modified on the springboard I want the poster screen roArray to represent the changes.

THX
0 Kudos
3 REPLIES 3
TheEndless
Channel Surfer

Re: Quick Brightscript questions

myString = "1"
If myString.ToInt() > 2 Then...

or you can use the Int() function...
myString = "1"
If Int( myString ) > 2 Then...

All objects are passed by reference, but as far as my testing has gone, it seems the data used for display is a copy, so you'll need to call SetContent and/or SetContentList again with the updated data to get the Poster and Springboard screens to update.
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)
0 Kudos
kbenson
Visitor

Re: Quick Brightscript questions

"TheEndless" wrote:

All objects are passed by reference, but as far as my testing has gone, it seems the data used for display is a copy, so you'll need to call SetContent and/or SetContentList again with the updated data to get the Poster and Springboard screens to update.


I imagine since components are supposed to be implemented in C/C++ that they are converting the data structures to a native format for the component, copying implicitly.

We routinely use shortcuts like so in KidPaint for purely brightscript constructs:

config = {
ui: {
tools: {
shape: { img: "file_path", size: "size_data", handler: "handler_routine" }
stamps: { img: "file_path", size: "size_data", handler: "handler_routine" }
}
}
}

shapeMeta = config.ui.tools.shape
shapeMeta.handler = "new_handler_routine"
print config.ui.tools.shape.handler ' prints "new_handler_routine"
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
EngoTom
Visitor

Re: Quick Brightscript questions

Thanks Guys...
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.