Your Digital Media Has Never Looked So Good

 
btpoole
Topic Author
Posts: 342
Joined: Fri Feb 15, 2013 2:08 pm

V7.6.0 callFunc()

Sun Jul 09, 2017 9:23 am

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
 
tim_beynart
Posts: 174
Joined: Wed Jul 15, 2015 8:30 am

Re: V7.6.0 callFunc()

Mon Jul 10, 2017 8:31 am

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)
Last edited by tim_beynart on Mon Jul 10, 2017 8:37 am, edited 1 time in total.
 
btpoole
Topic Author
Posts: 342
Joined: Fri Feb 15, 2013 2:08 pm

Re: V7.6.0 callFunc()

Mon Jul 10, 2017 8:33 am

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
 
tim_beynart
Posts: 174
Joined: Wed Jul 15, 2015 8:30 am

Re: V7.6.0 callFunc()

Mon Jul 10, 2017 8:50 am

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.
 
btpoole
Topic Author
Posts: 342
Joined: Fri Feb 15, 2013 2:08 pm

Re: V7.6.0 callFunc()

Mon Jul 10, 2017 9:04 am

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?
 
tim_beynart
Posts: 174
Joined: Wed Jul 15, 2015 8:30 am

Re: V7.6.0 callFunc()

Mon Jul 10, 2017 10:16 am

I only use it on components that extend Group and Task, not sure if functions are allowed on a Scene.
 
btpoole
Topic Author
Posts: 342
Joined: Fri Feb 15, 2013 2:08 pm

Re: V7.6.0 callFunc()

Mon Jul 10, 2017 4:45 pm

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. 
 
tim_beynart
Posts: 174
Joined: Wed Jul 15, 2015 8:30 am

Re: V7.6.0 callFunc()

Tue Jul 11, 2017 7:22 am

weird. 
I looked through my code and I only use functions in components that extend Group. Perhaps SG doesn't allow functions on Tasks? 
 
btpoole
Topic Author
Posts: 342
Joined: Fri Feb 15, 2013 2:08 pm

Re: V7.6.0 callFunc()

Tue Jul 11, 2017 7:35 am

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.
 
tim_beynart
Posts: 174
Joined: Wed Jul 15, 2015 8:30 am

Re: V7.6.0 callFunc()

Fri Jul 14, 2017 9:02 am

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
=================================================================

Who is online

Users browsing this forum: No registered users and 2 guests