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

Roku SceneGraph question

I have created a channel with many rows and many videos using Roku SceneGraph I have many functions that are the same except maybe one link is the a way to change the code to pull the rest of the function up from another file.
example
Every row needed will be using this and on the next row the only thing that is going to change is the function name and the url.SetUrl
 Function GetApiArray29()
url = CreateObject("roUrlTransfer")
url.SetUrl("http://myserver.com/test.rss")
rsp = url.GetToString()

responseXML = ParseXML(rsp)
responseXML = responseXML.GetChildElements()
responseArray = responseXML.GetChildElements()

result = []

for each xmlItem in responseArray
if xmlItem.getName() = "item"
itemAA = xmlItem.GetChildElements()
if itemAA <> invalid
item = {}
for each xmlItem in itemAA
item[xmlItem.getName()] = xmlItem.getText()
if xmlItem.getName() = "media:content"
item.stream = {url : xmlItem.url}
item.url = xmlItem.getAttributes().url


mediaContent = xmlItem.GetChildElements()
for each mediaContentItem in mediaContent
if mediaContentItem.getName() = "media:thumbnail"
item.HDPosterUrl = mediaContentItem.getattributes().url
item.hdBackgroundImageUrl = mediaContentItem.getattributes().url
end if
end for
end if
end for
result.push(item)
end if
end if
end for

return result
End Function

So I am trying to do something like
function it will have the two lines of code than go to another function to get the rest of the code. This way I can shorten the code. I hope i made sense of this. I just dont want to repeat the code over and over if i dont have to.
Thank you for you help
0 Kudos
3 REPLIES 3
belltown
Roku Guru

Re: Roku SceneGraph question

It will help to put your code within
[code][/code]
tags if you want anyone to make sense of it.
0 Kudos
mchiott09
Visitor

Re: Roku SceneGraph question

thank you belltown I went in and added [code][/code]
0 Kudos
Tyler_Smith
Binge Watcher

Re: Roku SceneGraph question

Can you not pass the unique values to your function?

Something like:

Function GetApiArray(urlPath)
url = CreateObject("roUrlTransfer")
url.SetUrl(urlpath)
rsp = url.GetToString()


etc etc
Tyler Smith
0 Kudos