Multiple Stack Instances

Klaus on-rev klaus at major.on-rev.com
Tue Oct 9 11:01:24 EDT 2012


Hi Andrew,

Am 09.10.2012 um 16:50 schrieb Andrew Kluthe <andrew at ctech.me>:

> This is kind of what I do already, Mark. I really want to allow them
> to have several open forms that they can minimize and pull back up as
> needed. There will probably only be about 4-5 maximum instances of
> this at a time. But I want to code 1 stack and have many instantiate
> copies of the stack. I can handle the data stores and all of that but
> how do I actually turn 1 stack into 4-5 stacks with script? Do I just
> 'copy stack "form" ' and if that is the ticket, how do I manage calls
> to that stack if they all use the same stack name? I''ve never
> constructed cards or stacks with scripts before.

here is what I did in the past:
1. Create your "form" stack as a mainstack will all elements and scripts
2. Save it to disk
3. Read it into a custom property:
...
set the cFormStack of this stack to url("binfile:" & pathtoyourmaistack)
...
4. open it and rename it immediately to avoid name conflicts like this:
...
put the cFormStack of this stack into tStack
go stack tStack
set the short name of stack "your_template_form" to ("form" & the seconds)
## or whatever the name of the original stack was
...

This way you can have some kind of template stack (not templatestack! ;-) 
create gazillions of instances from it and don't need to mess around with 
"clone" or whatever.

Sounds strange, but works like a charm :-D

> Thank you for the response,
> 
> Andrew Kluthe

Best

Klaus

--
Klaus Major
http://www.major-k.de
klaus at major.on-rev.com





More information about the use-livecode mailing list