Clone Renaming

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
Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Clone Renaming

Post by Not a lot of thought » Sat May 23, 2015 12:06 pm

So I have to rename a clone of a card within the code that creates the clone so that I may perform certain tasks. That clone then has to be moved from my template substack to my mainstack for use by the user. Can anyone help me with this?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Clone Renaming

Post by jmburnod » Sat May 23, 2015 12:45 pm

Hi,
Is your mainstack a standalone or not ?
Best regards
Jean-Marc
https://alternatic.ch

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Clone Renaming

Post by Not a lot of thought » Sat May 23, 2015 12:59 pm

What do you mean by standalone?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Clone Renaming

Post by jmburnod » Sat May 23, 2015 2:27 pm

A standalone is an executable application .app, a stack is a document .livecode
https://alternatic.ch

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: Clone Renaming

Post by SparkOut » Sat May 23, 2015 3:15 pm

It is very easy to make a basic copy of a card in a substack. The id of the newly copied card will be returned in the "it" variable, which you can grab and use to set the name for the new card.
When you create the new card, it will become the active card, so you might need to lock messages and screen to return to the original card you were on, without displaying the copied card (locking messages will stop the closeCard and openCard etc messages being fired, which you don't want if you just want to get back to where you were). Unless you want to end up on the new card, of course, in which case you only need the 3 lines from the middle of this script. (Strictly speaking, you only need two lines, but a purely personal foible of mine is that I hate just using the value in "it" without having stored it first.)

Code: Select all

   put the long name of this card into tOriginalCard
   lock messages
   lock screen
   --above optional

   copy card "template" of stack "thisTemplateSubstack" to stack "thisMainstack"
   put it into tNewCard
   set the name of tNewCard to "New Card Name"
   
   --below optional
   go card tOriginalCard 
   unlock messages
   unlock screen
I think Jean-Marc might have been asking about whether this is a standalone, because if it is, then you will not be able to save the new card, so the next time the app is run, the copied card will not exist. You would have to use one of the tricks like the "splashstack" technique in order to be able to save the stack with the new card in it.

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Clone Renaming

Post by Not a lot of thought » Sun May 24, 2015 7:05 pm

Thanks SparkOut. I used the clone command and it worked fine. However, I'm concerned about what you mentioned regarding the standalone .app file vs the .livecode file. Currently it is saving fine, but are you guys saying that in the deployed version of the application it won't save that card?

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: Clone Renaming

Post by SparkOut » Sun May 24, 2015 7:14 pm

All Operating Systems prevent changes to the running program. You couldn't take the handle of a bucket and lift it off the ground if you are standing in the bucket. Once you step out of the bucket you can lift it no problem.
It is quite straightforward to have a launcher application which opens a LiveCode stack, which then behaves just like a standalone application, but which can also be saved.
How are you planning to deploy your app? Mobile or desktop standalone?

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Clone Renaming

Post by Not a lot of thought » Sun May 24, 2015 7:43 pm

All of the above. I'd like to query information from a web-based server with the app being the client program from which the information is entered and queried.
Please excuse my ignorance, but how is copying a card inside the program and adding it to the navigational scheme while it is running like picking up a bucket while one is standing inside said bucket?
The essential premise I'm after is, in a basic form, a more interesting version of adding a subfolder to another folder (including the graphics required to signify that it has been selected, etc.) is that not possible?

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Clone Renaming

Post by Not a lot of thought » Sun May 24, 2015 7:47 pm

The purpose of the "subfolder" is to help organize the structure of the underlying database and communicate where the user is in that database more efficiently.

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: Clone Renaming

Post by SparkOut » Sun May 24, 2015 8:28 pm

Picking up a bucket while you are standing in it was meant to explain how it is impossible - you need to get out of the bucket before you lift it. Back to comparison with the application, you have to stop using the running application in order to save it. If you can't save it until you have already stopped using it, you need a way to make a launcher that becomes the running app, which then instructs the engine to open a data stack - the one which you use to add the cards. That stack, as a stack opened by the engine from the launching splashstack can be saved (if you put it in the right place).

If you do a search for splashstack you will find many threads which discuss the problem of saving a data stack in the right place and the right way to suit your situation.

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: Clone Renaming

Post by SparkOut » Sun May 24, 2015 8:36 pm

Perhaps a better comparison... You cannot make changes to your word processor program, but it can open and save documents that you edit.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Clone Renaming

Post by MaxV » Mon May 25, 2015 1:54 pm

Probably you are going the wrong way, you needs a sperate file, a sqlite database file. You need to store values, data, images, etc.
Sqlite is integrated in livecode, no installation needed, so it's very easy to use. 8)
This is a guide about SQLite: http://dl.acm.org/citation.cfm?id=1941943
And here some information about sqlite and livecode: http://livecode.wikia.com/wiki/SQLite
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”