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: 
pcnweb
Channel Surfer

Concatenation Issue

I have arrays holding my row info like so:

m.options
m.options1
m.options2
etc...

I want to pass them from roGridScreenEvent to my function by appending the msg.GetIndex() to m.options, ex:

myopt = m.options+msg.GetIndex()

but that fails - do you have to cast everything to strings, then to something else? Can't figure it out or find examples in the docs.
0 Kudos
5 REPLIES 5
RokuKC
Roku Employee
Roku Employee

Re: Concatenation Issue

"pcnweb" wrote:
I have arrays holding my row info like so:

m.options
m.options1
m.options2
etc...

I want to pass them from roGridScreenEvent to my function by appending the msg.GetIndex() to m.options, ex:

myopt = m.options+msg.GetIndex()

but that fails - do you have to cast everything to strings, then to something else? Can't figure it out or find examples in the docs.


If m.options is an array of integers, apparently from your example, then you would append a new one to it by doing m.options.Push( msg.GetIndex() ).
https://sdkdocs.roku.com/display/sdkdoc/ifArray
0 Kudos
pcnweb
Channel Surfer

Re: Concatenation Issue

Thanks for the reply, guess I wasn't clear - I want to concatenate a number to the end of the actual array name, ex:

m.options + 1 would become m.options1
0 Kudos
RokuMarkn
Visitor

Re: Concatenation Issue

Seems like it would be easier to make m.options be an array, so you could say m.options[2] rather than m.option2. But if you really want to do this, then yes, you must do string manipulations, like

name = "options" + index.ToStr()
value = m[name]


--Mark
0 Kudos
pcnweb
Channel Surfer

Re: Concatenation Issue

Thanks, both ideas are helpful!
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: Concatenation Issue

"pcnweb" wrote:
Thanks for the reply, guess I wasn't clear - I want to concatenate a number to the end of the actual array name, ex:

m.options + 1 would become m.options1


Ah, I see. Sorry, I hadn't understood the use case. Mark's suggestion to use an actual array rather than dynamic field names is a good one. 🙂
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.