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

NOT ENTERING FUNCTION

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>

0 Kudos
1 REPLY 1
TheEndless
Channel Surfer

Re: NOT ENTERING FUNCTION

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)
0 Kudos