Page 1 of 1

urlStatus on Windows does not work

Posted: Tue Mar 31, 2009 9:51 pm
by ale870
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!

Posted: Tue Mar 31, 2009 10:10 pm
by gyroscope
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?
:)

Posted: Tue Mar 31, 2009 10:14 pm
by ale870
Thank you, but it seems even UrlStatus(myUrl) return always "contated".
Terrible... I cannot make async downloads...

Posted: Tue Mar 31, 2009 11:03 pm
by Mark
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

Posted: Tue Mar 31, 2009 11:24 pm
by ale870
Thank you, I just tried it and works perfectly!
Great trick! :D