Page 1 of 1

Can I open up many instances of a single substack?

Posted: Fri Feb 17, 2012 10:00 am
by DangerousThing
Hi:

For an application I'm working on, I have a mainstack which contains a list of database items and a button to create a new item.

Every time somebody double-clicks on the list of items I want to open a new instance of a substack which displays an editor/display for the that particular item of data.

Can anybody help me?
-
Jay

Re: Can I open up many instances of a single substack?

Posted: Fri Feb 17, 2012 12:26 pm
by Mark
Hi Jay,

You need to clone your stack and rename it.

Code: Select all

clone stack "Original Stack"
set the name of it to ("New Stack" && the milliseconds)
Somehow every name needs to be unique. The milliseconds is not perfect but should be sufficient. You could also script a counter, which remembers how many "New Stacks" are open already or count them every time with a repeat loop that checks all open stacks.

Kind regards,

Mark

Re: Can I open up many instances of a single substack?

Posted: Fri Feb 17, 2012 3:24 pm
by DangerousThing
Thanks much, Mark!

I can use the name of the data item which, by definition, will be unique. For "new" items, I'll assign a "New Ship " & a counter, until the user names the item. And I'll check when the user wants to open something if it's already opened so that I can just bring that stack to the front.
-
Jay
Mark wrote:Hi Jay,

You need to clone your stack and rename it.

Re: Can I open up many instances of a single substack?

Posted: Sat Feb 18, 2012 1:44 am
by dunbarx
Wouldn't it be more compact and far easier to manage if you made a new card in a single stack rather than millions of new stacks?

Craig Newman

Re: Can I open up many instances of a single substack?

Posted: Sat Feb 18, 2012 1:57 am
by Mark
Craig,

That might be the case, but not if you want to be able to compare different items simultaneously in different windows.

Kind regards,

Mark

Re: Can I open up many instances of a single substack?

Posted: Sat Feb 18, 2012 2:27 am
by DangerousThing
Mark wrote:Craig,

That might be the case, but not if you want to be able to compare different items simultaneously in different windows.

Kind regards,

Mark
Thank you Mark. That is exactly what I'm trying to do.

If only there was a way to create a virtual clone of the stack without having to have it copied to the disk. Oh well.
-
Jay

Re: Can I open up many instances of a single substack?

Posted: Sat Feb 18, 2012 2:41 am
by Mark
Hi Jay,

I don't understand your last remark. Clones only exist in memory until you ave them.

Mark

Re: Can I open up many instances of a single substack?

Posted: Sat Feb 18, 2012 3:44 pm
by FourthWorld
DangerousThing wrote:If only there was a way to create a virtual clone of the stack without having to have it copied to the disk.
Mark is correct: when you clone a stack it''s a copy of the original in all respects except that it isn't associated with any file, living only in memory.

If you want to save a cloned stack you can set its filename property, and then use the save command to save it.

But without that, it's only in RAM, very much like creating a new document in most document-centric applications.

Re: Can I open up many instances of a single substack?

Posted: Sat Feb 18, 2012 8:08 pm
by Mark
Yes, that's what I said, indeed.

Re: Can I open up many instances of a single substack?

Posted: Sun Feb 19, 2012 1:28 am
by DangerousThing
Mark wrote:Hi Jay,

I don't understand your last remark. Clones only exist in memory until you ave them.

Mark
Thank you. I had only read the definition in the LiveCode dictionary and it just talks about the "newly created object".

Your clarification makes it sound absolutely perfect for my needs. I'll have to try it out later tonight.