Can I open up many instances of a single substack?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DangerousThing
Posts: 8
Joined: Tue Feb 14, 2012 4:55 pm

Can I open up many instances of a single substack?

Post by DangerousThing » Fri Feb 17, 2012 10:00 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

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

Post by Mark » Fri Feb 17, 2012 12:26 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

DangerousThing
Posts: 8
Joined: Tue Feb 14, 2012 4:55 pm

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

Post by DangerousThing » Fri Feb 17, 2012 3:24 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Sat Feb 18, 2012 1:44 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

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

Post by Mark » Sat Feb 18, 2012 1:57 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

DangerousThing
Posts: 8
Joined: Tue Feb 14, 2012 4:55 pm

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

Post by DangerousThing » Sat Feb 18, 2012 2:27 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

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

Post by Mark » Sat Feb 18, 2012 2:41 am

Hi Jay,

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

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Sat Feb 18, 2012 3:44 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

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

Post by Mark » Sat Feb 18, 2012 8:08 pm

Yes, that's what I said, indeed.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

DangerousThing
Posts: 8
Joined: Tue Feb 14, 2012 4:55 pm

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

Post by DangerousThing » Sun Feb 19, 2012 1:28 am

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.

Post Reply