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: 
matrixebiz
Roku Guru

Little code help

EDIT: Not needed anymore. Please delete thread. There is no outcome to this thread. Changed code direction. Thx

Hello, just wondering why the below code will display the working url properly when going down the list, in that, if the first link fails, it will go to the next one, then if that one fails will go to the next one but the problem is that if the first url link is good, it still goes down the list and if the last link is bad then the whole code doesn't work. 

url = "http://pastebin.com/raw/llwkkkcec"
If url <> "" Then url = "http://myserver1.com/ececeec.txt"
If url <> "" Then url = "http://myserver2.com/wecewwe.txt"
IDArray = getStreamId(url)

*Note to self try: 
If url <> "" then url = "http://myserver1.com/ececeec.txt" else url = "http://pastebin.com/raw/llwkkkcec"
If url <> "" then url = "http://myserver2.com/wecewce.txt" else url = "http://myserver1.com/ececeec.txt"
0 Kudos
16 REPLIES 16
EnTerr
Roku Guru

Re: Little code help

Good grief, no! You want to do something like this instead:

IDArray = getStreamId("http://pastebin.com/raw/llwkkkcec")
if idArray.count() < 1 then IDArray = getStreamId("http://myserver1.com/ececeec.txt")
if idArray.count() < 1 then IDArray = getStreamId("http://myserver2.com/wecewwe.txt")

Except i am not quite sure what comes from getStreamId(), so it's up to you to figure out what the return is if download/parse had failed there. I remember there was recent conversation viewtopic.php?f=34&t=96627 and even went to check there but what do i see - you deleted the source from there because "I modified the code successfully"... apparently not though. Don't make our life hard here - this is a "free clinic"  😉
0 Kudos
matrixebiz
Roku Guru

Re: Little code help

not needed
0 Kudos
matrixebiz
Roku Guru

Re: Little code help

not needed
0 Kudos
matrixebiz
Roku Guru

Re: Little code help

Hello, it didn't work 😞 the second url link is a txt file because I don't know how to make it a raw file like the pastebin link so I have to make the code read the txt file and convert the contents to the url
0 Kudos
matrixebiz
Roku Guru

Re: Little code help

trying this code again but I don't know why the If <> "" doesn't work for when the url is invalid? it seems to read that line anyway
url = "http://pastebin.com/raw/llwkkkcec"
If url <> ""
0 Kudos
RokuMarkn
Visitor

Re: Little code help

Your second line is asking if the url variable is equal to an empty string.  It will NEVER be equal to an empty string, because you just set it to the "http..." string in the previous line.  You don't want to be testing the url variable, you want to perform an http transfer from the server and see what comes back, like Enterr's code showed you.  Your two line code is not touching any server at all, it's just setting a variable to a string and then checking whether that variable is still equal to the string.

--Mark
0 Kudos
matrixebiz
Roku Guru

Re: Little code help

not needed
0 Kudos
RokuMarkn
Visitor

Re: Little code help

If I'm understanding you correctly (though I'm not at all sure of that), you want to use roUrlTransfer.GetToString:

xfer = CreateObject("roUrlTransfer")
xfer.SetURL(url)
new_url = xfer.GetToString()


--Mark
0 Kudos
matrixebiz
Roku Guru

Re: Little code help

not needed
0 Kudos