URL download -- how to wait until all done?

Eric Chatonet eric.chatonet at sosmartsoftware.com
Mon Mar 17 08:18:14 EDT 2008


Hi Nicolas,

According to the docs:

Caution!  Avoid using the wait command in a handler after executing  
the load command. Since the load command is non-blocking, it may  
still be running when your handler reaches the wait command. And  
since the load command is part of the Internet library and is  
implemented in a handler, the wait command will stop the download  
process if it is executed while the download is still going on. In  
particular, do not use constructions like the following, which will  
sit forever without downloading the file:

   load URL myURL
   wait until the URLStatus of myURL is "cached" -- DON'T DO THIS

The "How to Download Data from the Internet" tutorial might help you:
This stack explains how to test the user connection, an url validity,  
why and how to use get url or load url, retrieve data from framed  
pages, give an account of download progress, manage errors, display  
retrieved data (web pages, stacks, compressed or not), etc.

You will access this tutorial through "Tutorials Picker" a free  
plugin that interfaces with the So Smart Software website in order to  
display all available tutorials stacks directly from the web.
You will find it by going to http://www.sosmartsoftware.com/.
Revolution/Plugins or Tutorials section.

Best regards from Paris,
Eric Chatonet.

Le 17 mars 08 à 12:22, Nicolas Cueto a écrit :

> I'm having trouble getting a load url command
> to work as planned.
>
> On a card there's 24 small images, each of which,
> when clicked, plays one of 24 sounds. All 48 images
> and sounds are set by loading 48 http urls.
>
> What I'd like to happen is that the 24 images be not
> displayed until all 47 http urls have been downloaded
> (are in the cache?).
>
> This is the script I've been using :
>
> repeat ...
>   load URL tImgPath
>   wait until tImgPath is among the lines of the cachedURLs with
> messages
>   set the fileName of image "img" of group i to tImgPath
>   load URL tSndPath
>   wait until tSndPath is among the lines of the cachedURLs with
> messages
>   set the cpSndPath of image "img* to tSndPath
> end repeat
>
> Now, this was working, tho somewhat slowly. The full download would
> take anywhere from 3 to 15 seconds. But after I extended the card
> script
> which includes that load command, the full download takes much longer
> or even hangs.
>
> My first thought is, could a very long card script cause
> memory-related
> problems?
>
> Another thought is that I don't understand fully how "cachedURLs"
> works? I assume that the load command puts the downloaded
> files in some kind of temporary memory, so as to avoid having
> to download the same files again and again.
>
> My final thought was to check the archives. There, I found that the
> load command can be modified thus:
>
>   load URL  tURL with message tMessage
>
> So, I tried that, and, it *was* faster. However, the 24 images are
> not displaying all at once. Plus, I'm not sure what to do with
> the tMessage part; for now, I've just added an "on tMessage"
> to the script, but it doesn't do anything with the message.
>
> If I've explained myself well enough, any suggestions how I can
> make the URLs all download quickly and, to a user's eyes, invisibly?
>
> Thank you.
>
> --
> Nicolas Cueto

----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the Use-livecode mailing list