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

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” :wink:

not needed

not needed

Hello, it didn’t work :disappointed_face: 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

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 <> ""

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

not needed

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

not needed

“RokuMarkn” wrote:
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
Sorry, not sure what to do with that code

not needed

definitely not. Looks like you have a typo (mytest or myText ?), and regardless you are never setting the value of “mytest”

url = mytest

Pretty sure you want this instead;

url = readtextfromserver(ServerURL)

not needed

not needed

anyone have any thoughts on my last post?

Not needed anymore. Please delete thread. Thx