Load and stacks...
Dave Cragg
dave.cragg at lacscentre.co.uk
Sun Jan 21 18:53:01 EST 2007
On 21 Jan 2007, at 19:16, David Bovill wrote:
> I have not used "load" much... just starting some experiments. Am I
> right
> that you can "load" stacks and then go to the url and it will fetch
> the
> stack from the cache?
That's right. But don't be misled by thinking this is a special
feature of stacks that are downloaded by "load url". You can "go" to
any stack whose file data is held in any kind of "data container"
such as a variable, custom property or url. The following will work too:
on mouseUp
answer file ""
if it is not empty then
put url ("binfile:" & it) into tStackData
go tStackData
end if
end mouseUp
As any data retrieved by "load url" is held in a cache, and as
subsequent calls using "get url" will retrieve the data from the
cache, using "go url "http://whatever/whatever.rev" is just taking
advantage of the above feature. (What I'm trying to say is that "load/
get url" wasn't designed with the idea of opening stacks in mind. The
ability to do that is just a consequence of an already existing
feature.)
>
> The other thing I cannot figure out is how to find out the name of
> the file
> in the cache
Do you mean the name of the file, or the name of the stack? The
cachedUrls() function will return of the currently cached URLs. I
don't know of a straightforward way to get the name of a stack in the
url cache. Possible ways are to "toplevel" the url and then
immediately get the name of the topStack, or write the url to a local
file and get the stack name from the file.
> (and where the cache is).
It's just a local script variable in the libUrl script.
> It would be
> nice to store the cache somewhere permanent and take advantage of
> the asynch
> load.
You could use libUrlDownloadToFile to do an asynchronous load
directly to a file instead of the cache. Or in the callback message
for load, save the url to a local file. For example:
load url myUrl with message "loaded"
on loaded pUrl, pStatus
if pStatus = "cached" then
put url pUrl into url ("binfile:" & pathToLocalFile)
end if
unload url pUrl
end loaded
Cheers
Dave
More information about the use-livecode
mailing list