change name of card with script

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
pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

change name of card with script

Post by pascalh4 » Thu Aug 22, 2013 1:22 pm

Hello everyone.
I am a beginner and I gradually discovers the software.

I found the explanation for changing the name of a stack with a script and it works perfectly:

Code: Select all

set the name of stack "oldname" to "newname"
But when I use the same script for a card:

Code: Select all

set the name of card "oldname" to "newname"
the following error message appears:
button "Button": execution error at line 5 (Chunk: can not find card), char 18

Note: I have checked the spelling of the name of the card.

Could someone tell me what is my mistake?

Thank you!

Pascal.

Klaus
Posts: 14222
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: change name of card with script

Post by Klaus » Thu Aug 22, 2013 1:33 pm

Hi Pascal,

1. welcome to the forum! :-)

2. The syntax is correct and does indded work here in my little test!?'
Is that card in the same stack as that script?
Sure you did not rename that card earlier?

You can always check:
...
if there is a cd "oldname" then...
...


Best

Klaus

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: change name of card with script

Post by pascalh4 » Thu Aug 22, 2013 2:43 pm

Hi Klaus!

Thank you for the quick response.

The card has been renamed before my test, and no, my script is not in the same stack as the card.

Should I create a direction of "go to" type, or is there another method?

Note: The stack whose name changes is nor the same.

detail from my script.

Code: Select all

on mouseUp
   copy stack "modèle" -- copy of the substack "modèle" of the stack "lancement" 
   paste --create a stack with new name "copy of modèle"
   set the name of stack "copy of modèle" to "nouveau titre" -- change the old name with the new
   set the name  of card "cartemod" to "titre modifié"-- problem line
   close stack "lancement" -- to clear the stack and its substack
delete stack "lancement" -- to remove this stack of the project browser
   end mouseUp
Pascal

Klaus
Posts: 14222
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: change name of card with script

Post by Klaus » Thu Aug 22, 2013 2:59 pm

Bonjour Pascal,
pascalh4 wrote:..and no, my script is not in the same stack as the card.
Aha, then just add a correct "descriptor" and it should work:
...
set the name of cd "oldname" OF STACK "name of stack with the card here..." to "newname"
...
pascalh4 wrote:Should I create a direction of "go to" type, or is there another method?
Sorry, no capisce!?

But see above that should do the trick!


Best

Klaus

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: change name of card with script

Post by pascalh4 » Thu Aug 22, 2013 3:00 pm

In fact everything is working by adding these two lines (in bold)

copy stack "modèle"
paste
set the name of stack "copy of modèle" to "nouveau titre"
go to the stack "nouveau titre"
go to the card "cartemod"

set the name of card "cartemod" to "titre modifié"
close stack "lancement"
delete stack "lancement"


But is there a different or faster method?



Pascal
Last edited by pascalh4 on Thu Aug 22, 2013 3:36 pm, edited 2 times in total.

Klaus
Posts: 14222
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: change name of card with script

Post by Klaus » Thu Aug 22, 2013 3:34 pm

Hi Pascal,

OK, but 2 hints:
1. do not use:
go to THE card...
-> go to cd xyz
or
go to THE stack...
-> go to stack zyx
The keyword THE is for custom properties.

2. As I wrote in my first post, no need to GO to the stack and/or the card!
Just add a precise description of the card and you are done:
...
set the name of card "cartemod" OF STACK "nouveau titre" to "titre modifié"
## Cleanest and fastest solution :-)
...


Best

Klaus

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: change name of card with script

Post by pascalh4 » Thu Aug 22, 2013 3:48 pm

Klaus thank you very much for that.
I will do tests and I will continue my discovery.

I also want to ask a more general question about the topics. Where can I find an explanation of the icons of the questions (that means the little star, for example)
and how it should end this discussion.

Pascal

Klaus
Posts: 14222
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: change name of card with script

Post by Klaus » Thu Aug 22, 2013 3:54 pm

Sorry, don't understand "an explanation of the icons of the questions..."?

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: change name of card with script

Post by pascalh4 » Thu Aug 22, 2013 7:06 pm

Sorry for my bad English spoken (thank's google translate :oops: ).

I would like to know the meaning of the icons to the left of the topic discussed. (especially the star)
I tried to attach a photo, but I'm not happened.
I get this message: "Your account does not have permission to post links or domain/page references".

good evening

Pascal

Klaus
Posts: 14222
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: change name of card with script

Post by Klaus » Thu Aug 22, 2013 7:19 pm

Bonsoir Pascal,

ny french is even worse! :-D

OK, sorry, I have no idea what these icons mean 8-)

And you need to have > X (10? Sorry, also no idea...) postings
before you are allowed to post links and attachments.


Best

Klaus

pascalh4
Posts: 81
Joined: Thu Aug 22, 2013 12:50 pm

Re: change name of card with script

Post by pascalh4 » Thu Aug 22, 2013 7:59 pm

Guten Abend Klaus.

Thank you for everything. I have another request to make, but I'll make another topic tomorrow.

Pascal

Post Reply