Your Digital Media Has Never Looked So Good

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

NOT ENTERING FUNCTION

Wed Sep 28, 2016 4:42 am

I copied the procedure from the sdk but for some reason the getcontent() function is never entered. Why is this?  If i run the code under getcontent() from inside the init, it works. It does enter the init.

<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp.  All Rights Reserved. **********-->


<component name="ContentReader" extends="Task" >

 <interface>
    <field id="content" type="node" />

 </interface>


 <script type="text/brightscript">
<![CDATA[
 sub init()
 print "INT"
 m.top.functionName = "getcontent"
end sub

sub getcontent()
 Print "GETCONTENT"
 iconurl=[]
 scrollist=[]
 content= createObject("RoSGNode","ContentNode")
 url="http://rokulist.php"
 ut = CreateObject("roUrlTransfer")
 ut.SetUrl(url)
 rocontent = ParseJson(ut.GetToString())
 for each items in rocontent.items
 iconurl.Push(items.icon)
 end for

 scrollist=arraySlice(iconurl,0,5)

 for each item in scrollist
 items = content.CreateChild("ContentNode")
 items.HDSMALLICONURL = item
 ?items.HDSMALLICONURL
 end for

 m.top.content = content

end sub

 function arraySlice(arr, start=invalid, finish=invalid, step_=1):
 res = [ ]
 for Q = start to finish step step_:
    if step_ = 0 then print "ValueError: slice step cannot be zero" : STOP
    if start = invalid then if step_ > 0 then start = 0 else start = arr.count() - 1
    if finish = invalid then if step_ > 0 then finish = arr.count() - 1 else finish = 0
    if start < 0 then start = arr.count() + start 'negative counts backwards from the end
    if finish < 0 then finish = arr.count() + finish
    res.push(arr[Q])
 '?res
  end for
 return res
  end function



 ]]>
 </script>

</component>

 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: NOT ENTERING FUNCTION

Sat Oct 01, 2016 1:41 pm

There's nothing in the code you pasted that actually runs the Task.  You need to set the task's control to "RUN" to get it to spin up its thread.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

Who is online

Users browsing this forum: No registered users and 11 guests