Cloning a template card with code

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

anmldr
Posts: 381
Joined: Tue Sep 11, 2012 11:13 pm

Re: Cloning a template card with code

Post by anmldr » Thu May 21, 2020 5:43 am

Klaus wrote:
Wed May 20, 2020 8:15 pm
One can also check IT!
From the dictionary about "clone":
Great idea. I ran with that. I know that I am a noob but I gave this challenge a try.

Button located on the "Template" card. Just a place for the script.

Code: Select all

on mouseUp pButtonNumber
   clone this card
end mouseUp
On the "Template" card you could put this in the Card Script:

Code: Select all

on preOpenCard
   local newName
   
   get the short ID of this card
   put it into newName
   
   if the name of this card = newName then
      exit preOpenCard
   else 
      set the name of this card to newName
   end if
end preOpenCard
The card is named with it's short id. You could find any other naming scheme for the new card.

Linda

P.S. If it does not work, it still was good practice for me. ;-)

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”