Hypercard to Studio conversion

J. Landman Gay jacque at hyperactivesw.com
Wed Oct 4 15:00:42 EDT 2006


Gordon Shimizu wrote:
> Thanks for this.
> My main directory stack contain buttons that opens other stacks. I placed
> the close stack command in one of the button and it did close this main
> directory stack.  However, it did not open the stack that this button should
> have been linked to.  I used openStack and file name of the stack I wanted
> to open with this button but nothing happened.  I think I am missing the
> pathway to this stack I want to open.  Can you help?

HyperCard stored the paths to various stacks that the user had opened 
previously, and used those as a lookup list if it didn't know the file 
path to a particular stack. Revolution doesn't do that. There are two 
ways to make sure your stack locations are recognized.

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.

Make sure all your stacks are contained in the same folder (or 
subfolders of that folder.) Then set "the defaultfolder" to that folder. 
The defaultfolder is a Revolution property that stores the path to the 
folder on disk where all file lookups should occur. If all your stacks 
are in one folder, you can calculate the correct folder like this:

   get the filename of this stack -- path to your main directory stack
   set the itemDelimiter to slash -- all file paths use slashes
   put item 1 to -2 of it into theFolderPath -- negatives count from the 
end of the string
   set the defaultfolder to it -- now the default folder location is set

Once you have set the defaultfolder, all your stacks can be accessed 
through relative file paths to that folder:

   go stack "mystack.rev"

Or if it is in a subfolder of the defaultfolder:

   go stack "mySubFolder/mystack.rev"

Note that unless the stack is already open in memory, you need to supply 
the name of the stack file as it appears on disk, which in Revolution 
can be different from the name of the stack itself. This is another 
difference from HC.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list