Variable transfers Between Stacks and Sub-Stacks.

Dave dave at looktowindward.com
Thu Mar 29 08:33:30 EDT 2007


Hi,

I've written my own Message/Event Handling system which solves this  
problem plus a whole lot more.

Basically it works like this:

You have one stack that is the repository for all "Inter/Intra-Stack"  
data - Call it "DataManager". The other stacks (Call then "StackA"  
and "StackB"  gain access to the DataManager via the start using  
stack "DataManager" statement. There are then (at a minimum) two  
functions in the "DataManager" - "GetData" and "PutData".

The "PutData" and "GetData" functions take the form:

function PutData theKey,theData

-- Store "theData" using "theKey" in a Custom Property Set (Array) of  
the "DataManager" stack.

end PutData

function GetData theKey

-- Retreive "theData" using "theKey" from a Custom Property Set  
(Array) of the "DataManager" stack.

return theData
end GetData

Using this method there is no need for an additional external file  
and it can be used in lots of different projects. Also since the data  
is de-coupled from the Stacks that use it, whole stacks (or objects  
within Stacks) can be re-used in different projects.

This is the basic technique, in order handle all requirements  
(Setting Factory Defaults and Dynamically updating values), you have  
to build on this.

My ISM (Inter Stack Manager) module handles all this and a whole lot  
more. In order to do this it keeps a list of objects that are  
"Listening" for data of a certain "Key" and sends the data to a  
handler when it is changed. Using this method allows you to cut and  
paste objects (including Groups) from one stack to another without  
changing a line of code!

If you'd like more information of this, feel free to contact me.

All the Best
Dave


On 29 Mar 2007, at 12:52, Sarah Reichelt wrote:

>> So I've a main stack and sub-stack for preferences. I save and load
>> the variables as a stack (not text of xml - just yet) when I open and
>> close the substack. However, is there best practice for how to load
>> the variables on startup of the mainstack and then use them in the
>> mainstack - refereshing if people change the preferences (in the sub-
>> stack) while the application is running?
>
> If the data in the sub-stack is stored in a field, then it's really  
> easy:
>   put field "Data" of stack "Sub" into myVariable
>
> The mainStack always "knows" where it's sub-stacks are and can grab
> data from them directly.
>
> There is no need to use global variables (which are persistant and
> will not respond to change unless you script it), just use field data
> and retrieve it every time you need it. That way any changes will be
> implemented automatically.
>
> Cheers,
> Sarah
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list