Page 1 of 1
Do not want to go to the cloned card
Posted: Fri May 27, 2016 3:29 pm
by mrcoollion
I want to clone a card (in background) without actually going to that card.
The statement below works fine but after this part of the script the new card is shown and I need to stay on the card within the script the clone is initiated from (a button).
Code: Select all
clone card "Card template"
set the name of card "Card template" of this stack to thenewcardname // Because it is a clone it does not matter which card is renamed.
Workin in Livecode 8.0
Regards,
Paul
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 4:13 pm
by dunbarx
Hi.
Read about locking the screen in the dictionary. Now think about setting up a way to identify your source card, perhaps by marking or naming, and throwing in a line that returns to that card after the clone has been created. A shortcut might be that you exploit the fact that the cloned card will immediately follow the source card, but that is lazy.
Craig Newman.
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 4:34 pm
by mrcoollion
I will try some stuff , I think that lock screen and go back to original card will initiale the 'on opencard' routine which I do not want.
I will let you know.
Thanks Craig.
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 4:39 pm
by dunbarx
Well then lock messages as well.
This is a great tool to bypass stuff that you may want in some processes, but not in certain others.
Craig.
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 4:40 pm
by Klaus
Hi mrcoollion,
"lock messages" is the magic word!
Code: Select all
...
lock screen
clone cd X
lock messages
go cd "the previous one"
unlock messages
unlock screen
...
Best
Klaus
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 4:44 pm
by mrcoollion
Tried the lock screen and although it looks ok the on opencard routine is activated ;-( (which I expected to be).
Is there any other copy command i can use to copy a card and rename it?
gtestvar1 is a global variable available in open card
Code: Select all
on opencard
put "Past Opencard ;-(" into gtestvar1
end opencard
The code in a button in card "AddMenuItems"
Code: Select all
lock screen
put empty into gtestvar1
clone card "Card template" // Works but which card to change the name of?
set the name of card "Card template" of this stack to thenewcardname // Picks the first found but that does not matter. is is a clone anyway :-)
go card "AddMenuItems"
unlock screen
answer gtestvar1 // for test
regards,
Paul
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 5:27 pm
by Klaus
Hi Paul,
you already gave the answer!
Code: Select all
...
lock screen
put empty into gtestvar1
clone card "Card template"
## Works but which card to change the name of?
## You already found out that you ARE on the new card at this point! :-)
## So lets use this fact and:
set the name of THIS cd to thenewcardname // Picks the first found but that does not matter. is is a clone anyway :-)
go card "AddMenuItems"
unlock screen
answer gtestvar1
...
Best
Klaus
Re: Do not want to go to the cloned card
Posted: Fri May 27, 2016 11:18 pm
by dunbarx
Hi.
Both Klaus and I mentiined that you can lock messages (though I beat him by one minute. Hah!)
But you did see that (them) right?
Craig
Re: Do not want to go to the cloned card
Posted: Sat May 28, 2016 9:33 am
by mrcoollion
Thanks for all the advise friends.
The script below works fine and I will use it.
Code: Select all
lock screen
clone card "Card template"
set the name of card "Card template" of this stack to thenewcardname // Picks the first found but that does not matter, it is a clone anyway :-)
lock messages
go card "AddMenuItems" // This script is in a button on this card
unlock messages
unlock screen
I did not use the 'set the name of THIS cd to thenewcardname ' because after doing so I almost lost 2 weeks of work when it renamed the card my code was on and I almost removed it. I do auto sync my scripts to another safe place with BitTorrentSync but that is not a backup (in my opinion best free synctool available)! It made me aware of this and now I use 'cobian backup' to make a copy every minute of changed scripts (works great). It has an option to remove empty folders in the advanced section of a task so it actually only backups changed scripts (no performance problems at all,
http://www.cobiansoft.com).
Thanks for everything.
Regards,
Paul