Functional Documents Created by Application

Richard Gaskin ambassador at fourthworld.com
Sat Jun 10 15:43:17 EDT 2006


Joseph Martinez wrote:

> I have a technical issue that I hope the list can help me resolve.  I've
> been researching it for days, so now I realize it might just be better to
> ask the experts. 

Bringing issues to this list is generally useful, certainly better than 
spending another few days hacking it out yourself. :)  With this one 
move you're already more than halfway to your solution.

> I am creating an application that -- when opened --
> requires the user to either 1) create a stack or 2) open an existing stack
> (created by the App).
> 
> 1. When the user creates a stack, the App clones the mainstack so it has all
> the controls required and immediately enables the user to save it anywhere
> on the drive.  The new stack, however, would have almost no scripts of its
> own and just use the mainstack and substacks in the application for its
> script functionality.  The stacks in the App therefore would be in the new
> stack's message hierarchy.  Is this possible, and how would I get the App
> and stack to find each other?

If by "find each other" you mean associate the file type with the 
application?  On Mac this is a function of the plist file, created by 
the standalone builder, and on Windows this is a function of the registry.

For more background on this see Ken Ray's excellent notes at:

<http://www.sonsothunder.com/devres/revolution/tips/file005.htm>
<http://www.sonsothunder.com/devres/revolution/tips/file004.htm>


> 2. Also, when the user double-clicks on a previously created stack, it open
> the App that created it and likewise would use all the stacks in the App for
> functionality.  It's similar to the way a word processor works -- the app
> creates a blank document, and the document relies on the app to do
> everything it can do.  Is this too possible?

Not only possible, but common.

These apps are modest examples:
<http://www.macaddict.com/issues/2006/4/reviews/transcribe>
<http://www.fourthworld.com/products/sophie/index.html>

The standalone's mainstack script is available to all stacks run in that 
standalone, even separate stackfiles such as the documents.

> 3. Also, can the stacks created as "documents" retain their editable data
> whenever opened and closed using the structure above?  And, would this work
> cross platform?

Stacks are stacks, on any platform. Same format on each -- that's one of 
the nice things about using stack files for data storage.

To save them all you need is the save command.  In your File->Save menu 
item you'll want to check if the fileName property of the stack is empty 
(which means it's a fresh clone that has never been saved), and then 
call your Save As routine to bring up the ask file dialog so the user 
can save it.

--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list