copy and pasting more than 1 item

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
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

copy and pasting more than 1 item

Post by jalz » Wed May 21, 2014 11:05 pm

Hi Guys,

I've stumbled on an issue which I need a bit of assistance with please. I currently have a script
copy group "Purchases" of card "ItemLibrary" of stack "ItemLibrary"

which copies a layout object from one card and then using the paste function pastes it into a brand new card multiple times depending on the amount of data. This seems to works great!

I need to build more things onto that card, such as I would like to bring in logo, a footer etc. These are all objects that exist on different cards.I could use the same technique of copy and pasting the objects from one card/stack to another. However I believe the copy function only holds one object in memory and I need to hold and reference 4/5.

Is there a simple way I can copy 4/5 items that exist on separate stacks and paste them accurately on the card that script is working for.

Thanks as always
Jalz

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

Re: copy and pasting more than 1 item

Post by dunbarx » Thu May 22, 2014 3:33 am

Hi.

The "copy" command can only hold one object reference at a time. The good news is that this command is quite flexible:

copy sourceObject of card sourceCard of stack sourceStack to card destinationCard of stack destinationStack

That sort of thing.

Anyway, even if you were able to navigate around to collect several objects and place them all into one comprehensive "copy", you would require no more time to navigate around and copy one at a time.

Craig Newman

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: copy and pasting more than 1 item

Post by jalz » Thu May 22, 2014 11:00 pm

Thanks Craig,

That sorted it 75% of my copy and paste woes... I have another extended question regarding copy.

I have a text field on a card which contains some text. I want to copy the contents of that field into another card and place it in as a label field, i.e. in a non editable format. When I use the
copy sourceObject of card sourceCard of stack sourceStack to card destinationCard of stack destinationStack
this copies the text field across but not the actual text contents. I thought if I could copy the the field across with the content I could possibly then make the field not in focus, remove borders etc so it looks like a label field.

As the card I am copying to does not have a label field defined where I can "put" the content in, because the card is built up from scratch when requested by code. Is there an efficient way to transfer contents of a text field into a card which has no field objects defined.

Best
Jalz

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

Re: copy and pasting more than 1 item

Post by dunbarx » Thu May 22, 2014 11:53 pm

Hi.

I think I lost the post I made to you. Anyway,

I would set properties of the templateField to the properties of a typical label field. Then when you copy, the field should look right. Note that a label field is just a field, though with its own properties. This is all untested. For example, the text of the parent field is a property, but the text of the templateField might be anything. So you will at a minimum have to set this after copying. This is easy to do, fortunately.

Work this. Let me know how you fare. I expect you will have to do a bit of tweaking...

Craig

Post Reply