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).
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.
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.
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.
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
...
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
...
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).