Page 1 of 1
Script to delete unwanted cards.
Posted: Thu May 15, 2025 1:07 pm
by CAsba
Hi,
My project includes setting up a new card by copying a card template, then renaming it. LC also creates, at the same time, another, similar card with an id number such as card id 5723439, which can be seen as listed in the project browser.
At a later point in my project the user may be wish to delete the card from the archive, and my project has the facility to do this, by referring to the renamed card's name.
However, the card with id number that was created is not deleted. (Of course, the user does not know or care about this, but the system is fuller with it.)
I tried to add code using wildcard to delete the card with the id number, but without success.
Any ideas how solve this ?
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 1:29 pm
by dunbarx
CAsba.
When you say "LC also creates..." what do you mean? LC does not do this on its own, so are you saying it does? What am I missing?
In other words, are you saying LC creates an extra card each time you explicitly make one?
Craig
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 1:43 pm
by richmond62
LC also creates, at the same time, another, similar card
well, it will ONLY do that if you have told it to.
A computer can do almost nothing (beyond sitting on a table and looking like a box with some odd holes in its front) unless you tell it to: and remember GIGO.

Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 1:47 pm
by CAsba
I certainly haven't written any code to create tyhe second card; I imagined that it was some built in aspect of LC.
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 1:49 pm
by dunbarx
CAsba.
No.
You have to have done this somehow. Post your handler?
Craig
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 2:10 pm
by Klaus
Yes, please post the script!
I just made a quick test and this worked as exspected:
Code: Select all
on mouseUp
delete card id 1004
## May give a hint if it does NOT work, will be empty on success
answer the result
end mouseUp
Maybe you can add the line "answer the result" and see if and what it will tell you.
Where and when do you call that script to delete?
We cannot delete a card that has an object on it while its script is running.
Best
Klaus
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 3:42 pm
by stam
Why not iterate through all the cards in the stack and delete those where no name is given?
But I do echo Craig’s question, how/why are duplicate cards being created? Seems likely your card creation code has bug…
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 8:42 pm
by CAsba
The script is
Code: Select all
go to cd "template2"
clone cd "template2"
set the name of card "template2" to fld "d" of cd "start here"
go to cd fld "d" of cd "start here"
Re: Script to delete unwanted cards.
Posted: Thu May 15, 2025 9:00 pm
by Klaus
Hi CAsba,
looks like you are NOT renaming the cd "template2" but the card you want to clone!?
Try this:
Code: Select all
...
## No need to GO there, we can clone the card anyway
## go to cd "template2"
## First put the new name into a variable!
## This elmininates extra typing and makes it easier to debug, if neccessary.
put fld "d" of cd "start here" into tNewCardName
## We can already add the new name for the clone to this command:
clone cd "template2" AS tNewCardName
go cd tNewCardName
...
This should eliminate the need of deleting unwanted cards.
P.S.
"wildcards" do not work with "delete"!
Best
Klaus
Re: Script to delete unwanted cards.
Posted: Fri May 16, 2025 1:03 am
by stam
Klaus wrote: ↑Thu May 15, 2025 9:00 pm
Code: Select all
clone cd "template2" AS tNewCardName
Klaus is spot on - alternatively you can use the
long ID generated for the new object by the clone command, which is stored in the 'it' variable, so you could use something like:
Code: Select all
clone card "template2"
set the short name of it to <new_name>
But personally would go with c
lone card as <new_name> as Klaus suggest, keeps things simpler...
Re: Script to delete unwanted cards.
Posted: Fri May 16, 2025 9:53 am
by CAsba
Many thanks both - good to know you're still here !
Re: Script to delete unwanted cards.
Posted: Fri May 16, 2025 9:54 am
by Klaus
You're welcome!
And I'm always here.
Please tell us if this:
Code: Select all
clone cd "template2" AS tNewCardName
fixed the problem for you.