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

Cast variable or string as member function

Is there a way to use a variable, string, array key, etc., as a member function? Here's an example:

m.port=CreateObject("roMessagePort")
screen = CreateObject("roGridScreen")
screen.SetMessagePort(m.port)

' Assign the member function names to the array keys,
' and their respective values the array values.
gridAA = {
"SetDisplayMode": "scale-to-fill",
"SetGridStyle": "Flat-Movie"
}

' Issue is right here:
for each gridFunc in gridAA
gridVar = gridAA[gridFunc]
screen.gridFunc(gridVar)
next


As it's written this code is interpreting screen.gridFunc(gridVar) literally (which obviously won't work), so is there a way to cast gridFunc(gridVar) as a member function so that it can be called by screen (which in this case is an roGridScreen object)?
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.