Hypercard to Studio conversion
tereza at califex.com
Wed Oct 4 16:23:34 EDT 2006
On Oct 4, 2006, at 2:00 PM, J. Landman Gay wrote:
> The first way is to simply pass the full file path to the stack.
> You may not always know this in advance, but there are ways to
> calculate it. However, the easiest way is the second way, using
> relative file paths.
There is a related third way: using the "stackfiles" property. "The
stackfiles" is a stack property, consisting of a list of stacknames
and paths that Rev uses to find stacks that are referred to by name
in handlers. In Hypercard, I believe, the stackfiles property was
created and maintained by HyperCard itself, though it could be
modified by scripts.
From the Rev docs:
> When a handler or object refers to an object in a stack other than
> the current stack, Revolution checks all stacks that are loaded
> into memory (and their substacks) to find the referenced stack. If
> the stack cannot be found, Revolution checks the current stack's
> stackFiles property to locate the stack being referenced, and loads
> it into memory so that its properties and the objects in it can be
I do this: in my standalone stack startup sequence, my scripts get
the files in a subdirectory in a defined relationship to my
standalone, and from the file list the script creates a list of the
stacks I find there, like this:
Then I set the stackfiles of my standalone stack to this list.
Because the standalone stack is a "parent" stack to every stack in
the application, its stackfiles property is available to every script
in the application.
Since I always use the same name for my stacks and their filenames, I
can be confident that when I use this in a script:
the proper stack will be found and loaded.
I make this stackfiles list every time I start up the application, so
the paths are always current. Another strategy might be to fill the
stackfiles property once during development using relative paths. But
that relies on having "the defaultfolder" correctly set at all times.
Of course, I always restore the defaultfolder whenever I change it,
but I like the belt and suspenders approach. Besides, doing it the
full-path way would permit me to put stack files in more than one
directory - application stacks and plugins maybe - and find them
seamlessly in scripts.
Always another way...
Califex Software, Inc.
More information about the use-livecode