second instance of a stack

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
Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

second instance of a stack

Post by Preston Shea » Sat Mar 01, 2008 4:32 pm

how do you say
on mouseUp
open a copy of this stack in a new window and go to card XYZ of the newly opened stack
end mouseUp
In nova fert animus mutatas dicere formas corpora.

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

Post by Mark » Sat Mar 01, 2008 5:14 pm

Hi Preston,

Code: Select all

on mouseUp
  put the mainstack of this stack into myMainStack
  clone this stack
  put it into myNewStack
  set the mainstack of myNewStack to myMainstack -- optional
  go cd "XYZ" of myNewStack
end mouseUp
Untested, but should work.

Best,

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

mcgrath3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 149
Joined: Thu Feb 23, 2006 8:49 pm
Contact:

Post by mcgrath3 » Sat Mar 01, 2008 5:57 pm

Be careful as clone makes an exact copy with the same name as the original and this could cause some confusion in the message path. So if you do make a clone the first thing to do is rename the stack.
Tom McGrath III
Lazy River Software
3mcgrath@comcast.net

Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

Post by Preston Shea » Sat Mar 01, 2008 6:02 pm

Mark wrote:Hi Preston,

Code: Select all

on mouseUp
  put the mainstack of this stack into myMainStack
  clone this stack
  put it into myNewStack
  set the mainstack of myNewStack to myMainstack -- optional
  go cd "XYZ" of myNewStack
end mouseUp
Untested, but should work.

Best,

Thanks so much! You are a prince among men. I had to add "stack"
on mouseUp
put the mainstack of this stack into myMainStack
clone this stack
put it into myNewStack
set the mainstack of myNewStack to myMainstack -- optional
go cd "XYZ" of stack myNewStack
end mouseUp

Mark
In nova fert animus mutatas dicere formas corpora.

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

Post by Mark » Sat Mar 01, 2008 6:20 pm

mcgrath3 wrote:Be careful as clone makes an exact copy with the same name as the original and this could cause some confusion in the message path. So if you do make a clone the first thing to do is rename the stack.
This is not true.

Best,

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

Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

Post by Preston Shea » Sat Mar 01, 2008 8:32 pm

I have gotten the "stack with same name" message but no when running the stack as a standalone, which is my goal.
In nova fert animus mutatas dicere formas corpora.

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

Post by Mark » Sat Mar 01, 2008 8:37 pm

Hi Preston,

You get the error message because you do have a stack with that name already, perhaps because you clone twice.

In a standalone, error messages don't appear by default, but they do occur and you should not ignore them.

Best,

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

ThinKolistic
Posts: 5
Joined: Thu Apr 24, 2008 5:54 pm
Contact:

Post by ThinKolistic » Thu May 01, 2008 7:15 pm

mcgrath3 wrote:Be careful as clone makes an exact copy with the same name as the original and this could cause some confusion in the message path. So if you do make a clone the first thing to do is rename the stack.
I just made a copy of a file in the Mac finder, rather than rely on my 99.95% memory :idea: "copy" was appended to the duplicate, automatically.

Would that kind of concept help prevent confusion ? Would all the cards need name changes ?
George Wade
Horseshoe Bay
West Vancouver
"Japanese was easy
RunRev is different..!"

mcgrath3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 149
Joined: Thu Feb 23, 2006 8:49 pm
Contact:

Post by mcgrath3 » Fri May 02, 2008 4:45 am

No once the stack is renamed then each card can retain the same name. This is because the actual card is named: card "MyName" of stack "MyStack" ---- and ---- card "MyName" of stack "MyStackRenamed"

I usually use the whole name like this to avoid any issues with same name cards etc.

The same is true for objects: btn "MyButton" of card "MyName" of stack "MyStack" is different than btn "MyButton" of card "MyName" of stack "MyStackRenamed"

In a cloned stack there are now two stacks with the same scripts running that are calling items that are named the same and if you only write things like - send mouseUp to btn "MyButton" in 5 - then it could send this message to either btn "MyButton" when it comes down the object path.

It is just cleaner to use the whole object path to avoid these things.



Also, if you choose to change 'ALL' names in a stack then close the one stack and do a find/replace on the other stack for each name you want to change. find "MyButton" replace "MyButtonTwo"

HTH

Tom McGrath
Tom McGrath III
Lazy River Software
3mcgrath@comcast.net

Post Reply