urlStatus on Windows does not work

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

Post Reply
ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

urlStatus on Windows does not work

Post by ale870 » Tue Mar 31, 2009 9:51 pm

Hello, I'm using that flag to detect when a stack download was completed, but in Windows it always remain to "connected".
I even tried using my local Apache server or using my hosted remote site. Here the code:

Code: Select all

on openStack
   global myUrl
   
   local myTimer, myTimerStart
   
   put "http://127.0.0.1/stacks/fConsole.rev" into myUrl
   
   if myURL is not among the lines of the cachedURLs then 
      load url myUrl with message "downloadComplete"
      
      put 15 into myTimerStart
      put 0 into myTimer
      
      put "Looking for Console..." into field "labLoadInProgress"
      
      repeat while ( (the urlStatus of myUrl) is not "cached") and (myTimer < myTimerStart)
         put (the urlStatus of myUrl) & "..." && (myTimerStart - myTimer) into field "labLoadInProgress"
         wait for 0.5 seconds
         add 1 to myTimer
      end repeat
      
   else
      send "downloadComplete" to this stack in 1 milliseconds
   end if
   
end openStack

-----------------------------------------------------------------------------------------------------------

on downloadComplete
   global myUrl
   
   put "All done." into field "labLoadInProgress"
   wait 3 seconds
   
   go stack url myUrl
end downloadComplete
Cache does not work, infact it seems always empty, furthermore:

repeat while ( (the urlStatus of myUrl) is not "cached") and (myTimer < myTimerStart)


the flag (the urlStatus of myUrl) is always "connected".

Can you help me?
Thank you!

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Tue Mar 31, 2009 10:10 pm

Hi ale870, don't know if this would help: try

repeat while the urlStatus of myUrl is not "cached" and (myTimer < myTimerStart)
or
repeat while the urlStatus(myUrl) is not "cached" and (myTimer < myTimerStart)

maybe?
:)

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Tue Mar 31, 2009 10:14 pm

Thank you, but it seems even UrlStatus(myUrl) return always "contated".
Terrible... I cannot make async downloads...

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 31, 2009 11:03 pm

Dear ale870,

A wait command in combination with a load command doesn't work. Instead of the repear loop, use a send command.

Code: Select all

on downloadUrl
  put  "http://...." into myUrl
  load url myUrl with msg "foo"
  send "bar myUrl" to me in 200 millisecs
end downloadUrl

on bar theUrl
  put urlStatus(theUrl) into myStatus
  if myStatus contains "contacted" or myStatus contains "loading" then
    send "bar theUrl" to me in 200 millisecs
  end if
end bar

on foo
  put "done"
end foo
Actually, you may need to tweak the if statement in the bar handler a little more (and you will probably want to change the hander names).

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Tue Mar 31, 2009 11:24 pm

Thank you, I just tried it and works perfectly!
Great trick! :D

Post Reply