URL download -- how to wait until all done?

Nicolas Cueto niconiko at gmail.com
Mon Mar 17 07:22:36 EDT 2008

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

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

More information about the Use-livecode mailing list