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

copy paste stack

Post by pascalh4 » Tue Aug 27, 2013 3:31 pm

Hi
I'm back.

When I copy and paste a stack, a new stack "'copy of stack" is created.
To change the name, this code works perfectly.
copy
paste

set name of the stack "copy of aa" to "bb"

or

go to stack "copy of aa"
set name of this stack to "bb"
But if I replace stack "name" by this stack, the first stack is always renamed and not the copy.


How is it possible to rename the copy without using his name?

Pascal

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

Re: copy paste stack

Post by FourthWorld » Tue Aug 27, 2013 3:38 pm

With most commands in LC that create new objects, the local variable "it" will contain a reference to the newly-created object - try this in the Message Box:

Code: Select all

copy this stack; paste; put it
FWIW, while copy and paste will work, it will overwrite the user's clipboard, requiring you to store and restore the clipboard contents or your user may lose data.

LC includes a "clone" command as a way of copying objects without altering the clipboard - see its Dictionary entry for details.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: copy paste stack

Post by Klaus » Tue Aug 27, 2013 3:40 pm

Hi Pascal,
pascalh4 wrote:How is it possible to rename the copy without using his name?
Use "clone stack xyz" instead of "copy/paste" and then do this:
...
clone stack "aa"
## "clone" will put the long ID of the new object/card/stack into the variable IT
set the name of IT to "bb"
...

Best

Klaus

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

Re: copy paste stack

Post by pascalh4 » Tue Aug 27, 2013 5:06 pm

hi,
thank you both, that's exactly what I wanted.
Pascal

Post Reply