Copy a card to another

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Copy a card to another

Post by bsouthuk » Fri Apr 09, 2010 12:50 pm

Hello again.

I have another question and wonder if someone can point me in the right direction.

I have built a quote generating application and when selections are made within my application a user is able to generate a 'sales proposal'.

I am now looking to implement a feature where if a user was to add information on a specific card to the end of the 14 card proposal then all they have to do is click a button. This is pretty straight forward but I am stuck when it comes to if a user wants to add more than 1 card to the end of 14 card proposal.

Any ideas on a simple script that copies info on 1 card to the end of a 14 card proposal? And obviously if more than 1 card needs to be copied it will check if page 15 has any info on there and if so then to copy to page 16 and so on.

Hope this makes sense.

Cheers

Dan

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

Re: Copy a card to another

Post by Mark » Fri Apr 09, 2010 4:06 pm

Hi Dan,

What you want seems to be similar to

Code: Select all

put fld "Original Text" of cd 1 into fld "Copied Text" of cd 16
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

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Copy a card to another

Post by bsouthuk » Fri Apr 09, 2010 4:18 pm

Thanks Mark

Yes that's right, however say if the user has already copied a card into card 16. How can I script it so that it will then be copied to card 17. And if card 17 has already had a card copied to it then into card 18 and so on?

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

Re: Copy a card to another

Post by Mark » Fri Apr 09, 2010 4:32 pm

I'm not sure, Dan, but perhaps you could check whether fields are empty:

Code: Select all

repeat with x = 1 to number of cards
  if fld "Field to check" is empty then exit repeat
end repeat
put fld "Original Text" of cd 1 into fld "Copied Text" of cd x
Or you could always create a new card before copying:

Code: Select all

go last cd
create card
put fld "Original Text" of cd 1 into fld "Copied Text" of last cd
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

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: Copy a card to another

Post by bsouthuk » Fri Apr 09, 2010 7:14 pm

Thats perfect Mark thank you - all sorted.

Your help was most appreciated!

Post Reply