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

Cannot run Task

I'm trying to run the example from here without success.

Here is the code:


m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent")
m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml")
m.getHomeOptionsList.observeField("content", "showhomeoptionslist")
m.getHomeOptionsList.functionName = "showhomeoptionslist"
m.getHomeOptionsList.control = "RUN"



<?xml version = "1.0" encoding = "utf-8" ?>
 
<!--********** Copyright 2015 Roku Corp.  All Rights Reserved. **********-->
 
<component name = "getLabelListContent" extends = "Task" >
 
<interface>
  <field id = "uri" type = "uri" />
  <field id = "content" type = "node" />
</interface>
 
<script type = "text/brightscript" >
 
  <![CDATA[
 
  sub init()
    m.top.functionName = "getContent"
  end sub
 
  sub getContent()
    content = createObject("roSGNode", "ContentNode")
    contentxml = createObject("roXMLElement")
 
    readInternet = createObject("roUrlTransfer")
    readInternet.setUrl(m.top.uri)
    contentxml.parse(readInternet.GetToString())
 
    if contentxml.getName() = "listcontent"
      for each item in contentxml.GetNamedElements("item")
        attributes = item.getAttributes()
        item = {
          text: attributes.text
          }
        listitem = content.createChild("ContentNode")
        listitem.title = item.text
      end for
    end if
 
    m.top.content = content
  end sub
 
  ]]>
 
  </script>
 
</component>


I'm getting this error:


BRIGHTSCRIPT: ERROR: roSGNode: Failed to create roSGNode with type getLabelListContent: pkg:/components/screens/DetailsScreen/DetailsScreen.brs(101)

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected:  1*   ...ailsScreen/DetailsScreen.brs(102)    m.getHomeOptionsList.setField("uri", "http://www.sdktestingl

Current Function:
100:  sub runXMLTask()
101:          m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent")
102:*         m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml")
103:          m.getHomeOptionsList.observeField("content", "showhomeoptionslist")
104:          m.getHomeOptionsList.functionName = "showhomeoptionslist"
105:          m.getHomeOptionsList.control = "RUN"
106:  end sub
Interface not a member of BrightScript Component (runtime error &hf3) in [color=#0080e1][u]pkg:/components/screens/DetailsScreen/DetailsScreen.brs(102)
102:         m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml")


What Am I doing wrong? How do I fix this problem. Thanks for your help!
0 Kudos
5 REPLIES 5
tim_beynart
Channel Surfer

Re: Cannot run Task

From the docs, emphasis mine:
Sets the value of the subject node field identified by fieldName to value. This will fail and stop script execution if the value is not of the appropriate type. Returns true if the field is successfully set, false otherwise.


Looks like a typo in the the getLabelListContent component definition. I have no idea what a "uri" type is, is that a valid BrightScript data type? Change "uri" to "string". 

<interface>
  <field id = "uri" type = "string" />
  <field id = "content" type = "node" />
</interface>
0 Kudos
neowinston
Visitor

Re: Cannot run Task

Hello Tim,

Thanks for your reply. 

I've modified the code as you suggested, but I'm still having the same error:


101:          m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent")
m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml")
103:          m.getHomeOptionsList.observeField("content", "showhomeoptionslist")
104:          m.getHomeOptionsList.functionName = "showhomeoptionslist"
105:          m.getHomeOptionsList.control = "RUN"
106:  end sub
Interface not a member of BrightScript Component (runtime error &hf3) 


Any other suggestion? Someone said that I'd have to run the code on the Main Thread but I have no idea about how to do that. 
0 Kudos
tim_beynart
Channel Surfer

Re: Cannot run Task

check to see if the component is created successfully:
m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent")
? "DID THIS WORK???", m.getHomeOptionsList
0 Kudos
neowinston
Visitor

Re: Cannot run Task

Hello Tim,

Yes, it's working fine now, thanks for the code. Would you please take a look on this question that I need some help with:

https://forums.roku.com/viewtopic.php?f=34&t=105060

Thank you!
0 Kudos
developer34
Channel Surfer

Re: Cannot run Task

I am also having same problem in my code can you please help me

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.