LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 3:18 pm
I have problem with put Url sequence of script code:
When my script is:
Code: Select all
put url "http://www.nbp.pl/home.aspx?f=/kursy/kursyc.html" into msg
it puts expected html page source into msg box.
Also if my script is:
Code: Select all
put url "http://www.nbp.pl/kursy/xml/c027z140210.xml" into msg
it's working, I have xml text in msg box.
But if I have both:
Code: Select all
put url "http://www.nbp.pl/home.aspx?f=/kursy/kursyc.html" into msg
put url "http://www.nbp.pl/kursy/xml/c027z140210.xml" into msg
the msg box is empty, there is no xml text.
Is it possible I'm doing something wrong?
Marek
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 3:57 pm
No, even more then few minutes of wait doesn't help. First put url statement finishes loading, then I parse next url from downloaded html code. I have correct parsed url before second put url statement. I used "static" urls as text in put url statements to check why is this error, and to send short code making problem only.
Marek
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Mon Feb 10, 2014 4:05 pm
Hi Marek,
I also see what you describe. First I thought it was the bank blocking access to xml if accessed in too short intervalls.
this works for me
Code: Select all
put url "http://www.nbp.pl/home.aspx?f=/kursy/kursyc.html" into msg
put url "http://www.nbp.pl/kursy/xml/c027z140210.xml" into msg
put url "http://www.nbp.pl/kursy/xml/c027z140210.xml" into msg
I just don't know why.
Maybe someone has an idea?
Kind regards
Bernd
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 4:55 pm
Hi Bernd,
Thanks a lot for next help. Your solution is working perfect.
I have also no idea what could be the reason.
Marek
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Mon Feb 10, 2014 5:00 pm
snm wrote:I have also no idea what could be the reason.
Marek
What's happening if you do something like that:
put url ... into msg1
put url .... into msg2
put msg1 && msg2
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 5:17 pm
msg2 is empty if urls are in sequence shown as problematic in my first post.
Marek
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Mon Feb 10, 2014 5:37 pm
Umm, did the same test as Bernd with success...
No idea

!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 5:47 pm
Is it not happened until now LC bug? I checked it on versions 5.0.2 to 6.5.2 (MacBook Pro, 10.8.5) - the same problem.
Marek
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Mon Feb 10, 2014 6:09 pm
Hi Marek,
I am not shure if it is a bug but would consider it as a bug unless someone gives a good explanation for this behavior.
Unfortunately you are very good at discovering bugs in LC
Until someone has a better idea I would encapsulate this "bug" or bug like this
Code: Select all
on mouseUp
put "http://www.nbp.pl/home.aspx?f=/kursy/kursyc.html" & cr & "http://www.nbp.pl/kursy/xml/c027z140210.xml" into tURLList
repeat with i = 1 to the number of lines of tURLLIst
put getURL (line i of tURLList) into tRes
if tRes <> "" then
put tRes -- tried 10 times and could not get URL
exit mouseUp
end if
end repeat
end mouseUp
function getURL pURL
repeat 10 -- try 10 times, if success before return "" to stop repeat
put url pURL into msg
if the result is "" then
return ""
end if
end repeat
return "error in getting URL" && pURL
end getURL
Or something similar. This works for me.
That way you don't get stuck if it fails to work
Kind regards
Bernd
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 6:58 pm
Hi Bernd,
I don't know second url until I parse it from html from first url. The name of xml file i must download is changing minimum once a day. I'm worry only if put second url twice always will be enough. So basing on your help I have idea to check if will work:
Code: Select all
on mouseUp
local tHtml, tUrl, tXml, tNode
put url "http://www.nbp.pl/home.aspx?f=/kursy/kursyc.html" into tHtml
get matchText (tHtml, "(/kursy/xml/[a-zA-Z0-9]+\.xml)" , tUrl)
put "http://www.nbp.pl" & tUrl into tUrl
repeat with i=1 to 10
put url tUrl into tHtml
if tHtml is not empty then exit repeat
end repeat
put revXMLCreateTree (tHtml, false, true, false) into tXml
put revXMLRootNode (tXml) into tNode
put revXMLTree (tXml, tNode, return, space, true, -1) into fld "xml"
revXMLDeleteAllTrees
end mouseUp
Until now it works
Once more thanks a lot for your help Bernd,
Marek
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Mon Feb 10, 2014 7:10 pm
Marek,
you should 1 conditional that tests for tHTML, see code.
Code: Select all
on mouseUp
local tHtml, tUrl, tXml, tNode
put url "http://www.nbp.pl/home.aspx?f=/kursy/kursyc.html" into tHtml
get matchText (tHtml, "(/kursy/xml/[a-zA-Z0-9]+\.xml)" , tUrl)
put "http://www.nbp.pl" & tUrl into tUrl
repeat with i=1 to 10
put url tUrl into tHtml
if tHtml is not empty then exit repeat
end repeat
if tHTML is "" then -- if after 10 tries still no text then exit
answer "failure to retrieve URL"
exit mouseUp
end if
put revXMLCreateTree (tHtml, false, true, false) into tXml
put revXMLRootNode (tXml) into tNode
put revXMLTree (tXml, tNode, return, space, true, -1) into fld "xml"
revXMLDeleteAllTrees
end mouseUp
The way you had it the code would have proceeded after 10 tries even without success and the rest of your code would have failed. It is just to make shure you don't run into a problem with this hack.
And I am sure you just added RegEx to please Thierry...

Kind regards
Bernd
-
snm
- VIP Livecode Opensource Backer

- Posts: 253
- Joined: Fri Dec 09, 2011 11:17 am
Post
by snm » Mon Feb 10, 2014 7:47 pm
Yes Bernd, I didn't finnish this code yet but remember about checking all possible conditions. Actually I was working on another part of this job, but didn't want to keep you waiting for soon response. But thanks for reminder. It's fantastic to have friends who take care of quality and safety of your code.
I'm trying to learn RegEx, so I try to use it as often as possible. But of course it was for Thierry's pleasure - I knew he will want to help also
Marek
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Mon Feb 10, 2014 8:47 pm
snm wrote:I'm trying to learn RegEx, so I try to use it as often as possible. But of course it was for Thierry's pleasure
Marek
Thanks guys! You are too nice
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!