Advice on: sharing data between stacks
Alex Tweedly
alex at tweedly.net
Mon Jun 6 16:24:26 EDT 2005
Emilio Gagliardi wrote:
> Hello,
> I was wondering what the best mechanism is to share data between
> loaded stacks. I am trying to build a utility stack (that will
> always load first. I guess that makes it a standalone application)
> that gathers some demographic information, loads a second stack,
> which performs some custom task based on the demographic data,
> accepts data from the second stack, and writes a combination of the
> user data and retrieved data to a file. The second stack is
> dynamically selected (based on the directory structure and file
> nomenclature) so I want to make the sharing generic. But I am new to
> runrev so this might not be a good idea.
>
> The plan is to create the utility standalone application to be
> dropped onto a parent directory. The user selects some child
> directory (modifying defaultfolders) which contains a custom stack
> for performing some function.
why modify defaultfolder ?
> The custom stack generates lists or arrays of data and calls a
> handler in the utility application to handle the writing of data to
> disk. The premise is that many different people will write the
> custom stacks to do various unrelated tasks, but they all must save
> data in a consistent format to a central location. I want to move
> the code, which writes the data to a file, out of each custom stack
> and place it in a central stack because then the end user doesn't
> have to worry about the mechanics or guidelines that I impose when
> writing the data file.
You could simply put the "write to disk" handler in the main stack, and
then it would be available from within each of the other stacks.
> Here is how I envision the usage
>
> /Disk/Parent/GenericStack.rev
> 1) user selects a directory
> 2) directory contains another stack (ex. load great grandchild 2)
This sounds like you'll (potentially) finish up with a custom stack for
each child (or grandchild); I'd worry this could lead to code
duplication between all these stacks. Could you not simply store data
specific to that child, with a central set of custom stacks for
different categories.
> 3) user provides data for several variables (ex. a file name)
> 4) pass file name to great grand child2
> 5) write data from great grand child 2 to file
>
> /Disk/Parent/Child/Grandchild/GreatGrandChild.rev
> 1) use file name from GenericStack
> 2) do some task
> 3) pass the data back to GenericStack.rev
>
> /Disk/Parent/Child/Grandchild/GreatGrandChild2.rev
> 1) use file name from GenericStack
> 2) do some task
> 3) pass the data back to GenericStack.rev
This last step
3) pass the data back to GenericStack.rev
can be as simple as calling the handler(s) defined in the main stack.
Then what you described as
" but they all must save data in a consistent format to a central
location."
becomes simply passing the data to those handlers.
You might want to review Richard's Message Hierarchy tutorial to make
sure you know all the options for doing this as easily as possible.
http://www.fourthworld.com/embassy/articles/revolution_message_path.html
or check out what he's said in the latest scripting conference, via
<http://support.runrev.com/scriptingconferences/>
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.2 - Release Date: 04/06/2005
More information about the use-livecode
mailing list