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

V7.6.0 callFunc()

Does the callFunc() feature work in V7.6? Trying to use it based on the sdk and only getting an error that Interface not a member of BrightScript Component (runtime error &hf3). Setting it up as follows.

dialoginterface.xml

<?xml version = "1.0" encoding = "utf-8" ?>
<component name = "mydialog" extends = "Scene" >
  <interface>
<function name = "generalDialog" />
    </interface>
<script type="text/brightscript" uri="pkg:/components/dialogs/Dialogs.brs" />

  <script type = "text/brightscript" />
</component>


setinfo.brs


function setinfo()
dialogtitle="TITLE TEST"
dialogmessage = "MESSAGE TEST"
params = {title:dialogtitle, message:dialogmessage}
m.mydialog.callFunc("generaldialog", params)
end function




dialogs.brs
function generalDialog(params as Object) as Object
?"in generalDialog"
title= m.top.findNode(title)
message=m.top.findNode(message)
m.background  = m.top.findNode("Background")
example = m.top.findNode("instructLabel")
examplerect = example.boundingRect()
centerx = (1280 - examplerect.width) / 2
centery = (720 - examplerect.height) / 2
example.translation = [ centerx, centery ]
m.top.setFocus(true)
di = CreateObject ("roDeviceInfo")
serial=di.GetDeviceUniqueId()
dialog = createObject("roSGNode", "Dialog")
dialog.title = title
dialog.optionsDialog = true
dialog.message = message
m.top.dialog = dialog
end function
0 Kudos
9 REPLIES 9
tim_beynart
Channel Surfer

Re: V7.6.0 callFunc()

Maybe the function name is case sensitive when using callFunc? you are calling "generaldialog" but the function is defined as "generalDialog". Just a guess.

also, what's up with this code? you aren't using your params and the findNode call expects a string.
title= m.top.findNode(title)
message=m.top.findNode(message)
0 Kudos
btpoole
Channel Surfer

Re: V7.6.0 callFunc()

"tim_beynart" wrote:
Maybe the function name is case sensitive when using callFunc? you are calling "generaldialog" but the function is defined as "generalDialog". Just a guess.

You maybe correct. I'll try and post whether it made a difference.  Thanks for the catch.

Update: matching the case didn't fix it. Still get Interface not a member of BrightScript Component (runtime error &hf3).
Thanks anyway
0 Kudos
tim_beynart
Channel Surfer

Re: V7.6.0 callFunc()

FWIW, I am using callFunc extensively without issue. The biggest mistake I keep making is defining a function then calling it with dot notation like I am using a normal language, ha ha.
You should comment out all the code in your function except a print statement, then test. posting the actual telnet log would help.
0 Kudos
btpoole
Channel Surfer

Re: V7.6.0 callFunc()

"tim_beynart" wrote:
FWIW, I am using callFunc extensively without issue. The biggest mistake I keep making is defining a function then calling it with dot notation like I am using a normal language, ha ha.
You should comment out all the code in your function except a print statement, then test. posting the actual telnet log would help.

Are you creating the interface field in a scene as I have done in the code above?
0 Kudos
tim_beynart
Channel Surfer

Re: V7.6.0 callFunc()

I only use it on components that extend Group and Task, not sure if functions are allowed on a Scene.
0 Kudos
btpoole
Channel Surfer

Re: V7.6.0 callFunc()

I have pretty much cut it down to nothing  and getting error "Member function not found in BrightScript Component or interface."

mysetup.brs
function mysetup()
m.mytestTask=CreateObject("RoSGNode", "mytest")
m.mytestTask.callFunc("functiontest")
end function

functiontest.xml

<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp.  All Rights Reserved. **********-->
<component name = "mytest" extends = "Task" >
  <interface>
<field id = "content" type = "node" />
<function name = "functiontest" />
</interface>
 <script type="text/brightscript" uri="pkg:/components/functiontest.brs" />
<script type = "text/brightscript" />
</component>


functiontest.brs
function functiontest()
?"I AM HERE"
end function

All of the above files are located  pkg:/components directory. I understand the error but not sure why it's not seeing the function. 
0 Kudos
tim_beynart
Channel Surfer

Re: V7.6.0 callFunc()

weird. 
I looked through my code and I only use functions in components that extend Group. Perhaps SG doesn't allow functions on Tasks? 
0 Kudos
btpoole
Channel Surfer

Re: V7.6.0 callFunc()

"tim_beynart" wrote:
weird. 
I looked through my code and I only use functions in components that extend Group. Perhaps SG doesn't allow functions on Tasks? 

I'll try that and see what happens. I don't think I can cut it down much more than what I posted. Not sure if it makes any difference but during the process of trying to call the function I have a busy spinner running, not sure but maybe this causes a problem. Thanks for looking.
0 Kudos
tim_beynart
Channel Surfer

Re: V7.6.0 callFunc()

I just tried to add a function interface to a Task, and it doesn't work. I guess the Task node type doesn't support this.

=================================================================
Warning calling function in myTask
no function interface specified for test
=================================================================
0 Kudos