Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
jerdiggity
Level 7

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