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

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.

“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"

Thanks Guys…