Does a card script get copied when you make a new card?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
planix
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 47
Joined: Tue Mar 10, 2009 12:47 pm

Does a card script get copied when you make a new card?

Post by planix » Mon Feb 15, 2010 12:56 am

Hi,

I am developing a small card based data management tool. Each card is the same and I am using grouped backgrounds to keep the data entry fields and buttons the same across cards. But, I also have a script in the card which sets a global variable to keep track of which is the current card (this is accessed from another stack to grab info from the current card to produce a report).

My problem is that when I copy a card the card script from the original card is not in the copied card. I am using "create card" in order to get a card with all the fields emptied. Is this what should happen? Or does create not copy the card level script over? This is what I suspect is the problem. If so, is there a simple workaround?

cheers

Alistair
****************************************
PLANIX
"Knowing anything is better than knowing nothing. But knowing that nothing ain't anything, why that's just plain nirvana."

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Does a card script get copied when you make a new card?

Post by BvG » Mon Feb 15, 2010 1:04 am

create will make a new card. Although all background groups that are on the current cards will be placed on the new card, it's still a new card, and not a copy. So you want to copy or clone the card, instead of creating a new one.

try the copy command, or the clone command, instead of the create command.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

planix
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 47
Joined: Tue Mar 10, 2009 12:47 pm

Re: Does a card script get copied when you make a new card?

Post by planix » Mon Feb 15, 2010 1:53 am

Hi,

Thanks. I have tried these and both copy over the data in the fields. I have set the Share Text propert of the relevant fields to false and this still happens. So maybe this only works with the create command?

I did find a work around. It's probably better programming rather than a workaround. I put an OpenCard command in the stack script and wrote a script to put the name of the current card into the global variable. This works exactly the way that I want it to.

cheers

Alistair
****************************************
PLANIX
"Knowing anything is better than knowing nothing. But knowing that nothing ain't anything, why that's just plain nirvana."

Post Reply