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>