copy to mainstack 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
pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

copy to mainstack substack

Post by pascalh4 » Mon Sep 09, 2013 11:07 am

Hi

Here's another question about stacks manipulation.

Is it possible to copy or clone a mainstack to become the substack of a second mainstack.

In all my tests the copy is always a mainstack.

Pascal

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: copy to mainstack substack

Post by Klaus » Mon Sep 09, 2013 11:49 am

As I wrote in another posting, make your stack a substack with script!
Every "cloned" (and copy/pasted) stack is first a MAINSTACK:
...
clone stack "my stack"
set the mainstack of stack "copy of my stack" to "the other mainstack..."
...

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: copy to mainstack substack

Post by pascalh4 » Mon Sep 09, 2013 12:31 pm

Hi Klaus

Ok it works. I did not understand everything at the first explanation.

But I do not understand why it should be noted "the mainstack of stack".
Why not just stack (because at the moment there is no substack)

With a code that starts with "go to" for example, it's not necessary to specify "Mainstack of" to be recognized as a stack. Only his name is required (right?)

So what is the reason for this distinction? (I hope not to be too curious).

Pascal

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: copy to mainstack substack

Post by Klaus » Mon Sep 09, 2013 12:55 pm

Well, that's the ONLY way to make stack "A" a substack of stack "B":
...
set the MAINSTACK of stack "A" to "B"
...
And it is the only command in Livecode where you use the term "MAINSTACK" :D

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: copy to mainstack substack

Post by pascalh4 » Mon Sep 09, 2013 1:41 pm

Well I'll try to remember.

Thank you very much. :D

Pascal

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: copy to mainstack substack

Post by jacque » Mon Sep 09, 2013 11:38 pm

pascalh4 wrote:But I do not understand why it should be noted "the mainstack of stack".
Why not just stack (because at the moment there is no substack)
A file on disk can have several stacks in it, but there can only be one primary stack. All the others must be substacks. The primary stack is called the mainstack, and when you set a stack's "mainstack" property, you are telling the engine to attach the stack to the same file on disk as the main stack, which causes it to become a substack.

When referring to a stack in a script, you don't need to specify whether it is a mainstack or not, but when you want to change the relationship of a stack to another one, you can set its mainstack property.

You can also use "mainstack" to find out which stack is the owner of a substack: "put the mainstack of this stack" gives the name of the substack's owner (the primary stack in the file.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply