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

Checking existence of function

I was testing my channel on an older Roku running Firmware 3.1 and got this error

Member function not found in BrightScript Component or interface. (runtime error &hf4) in ...G56RN/pkg:/source/appMain.brs(98)
098: busydialog.EnableOverlay(true)

which leads to two questions.

1) Is there a way to check if an function is available before calling it? For example in javascript you could do this
if (busydialog.EnableOverlay) {
busydialog.EnableOverlay(true)
}

2) according to the docs (http://sdkdocs.roku.com/display/sdkdoc/ifMessageDialog) the EnableOverlay is listed as available since version 2.7. So why does it fail on a 3.1 box?
0 Kudos
3 REPLIES 3
belltown
Roku Guru

Re: Checking existence of function

I'm pretty sure I've used ifMessageDialog.EnableOverlay(true) with the 3.1 firmware. Are you sure that busydialog really is an roMessageDialog? Try putting a breakpoint (stop) before the call and print type(busydialog)

As far as testing if specific functions are supported, I don't know if that's possible, although you can test for specific firmware versions using roDeviceInfo. I'm sure there are a zillion different ways of doing this; here's one of the methods I use:


Function getRokuVersion () As Object
vsn = {major: 0, minor: 0, build: 0}
diVsn = CreateObject ("roDeviceInfo").GetVersion ()
majMin = (Mid (diVsn, 3, 4)).Tokenize (".")
If majMin.Count () > 0 Then vsn.major = majMin [0].ToInt ()
If majMin.Count () > 1 Then vsn.minor = majMin [1].ToInt ()
vsn.build = (Mid (diVsn, 9, 4)).ToInt ()
Return vsn
End Function

' Example use:
vsn = getRokuVersion ()
settings.seekSupported = vsn.major >= 5
0 Kudos
JesUltra
Streaming Star

Re: Checking existence of function

The global function FindMemberFunction is described to return "Invalid" if the function does not exist, or otherwise a reference to the interface defining the function.  I do not know from what version FindMemberFunction is available, though.

FindMemberFunction(object as Object, funName as String) As Interface
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: Checking existence of function

FindMemberFunction has been around for many years.  To be exact, the old release notes in the SDK documentation says it was added in Roku OS version 6.1 - 12/04/2014.

Generally speaking, for any function that is documented in the current SDK BrightScript reference without any annotation regarding it only being added in a recent firmware version, you can take its availability for granted.

 

0 Kudos