Page 1 of 1
A group that can delete itself
Posted: Tue Feb 19, 2019 10:13 am
by kaveh1000
I have a number of groups on a card. I want a button on each group that deletes the entire group (including itself) when clicked.
I attach my minimal example and can't find a way to do this. I am sure obvious for the gods on this forum! Any ideas pls?
Re: A group that can delete itself
Posted: Tue Feb 19, 2019 11:18 am
by bogs
kaveh1000 wrote: ↑Tue Feb 19, 2019 10:13 am
I am sure (it is?) obvious for the
gods on this forum! Any ideas pls?
Sure, we've got
lots of ideas, come back on the 8th day, we're a little busy right now.
signed : local wood sprite
(Just kidding

)
First, let me ask if you already saw 'deleteGroup' in the dictionary. If not, it has an example attached to it-
Code: Select all
on deleteGroup -- remove the group being deleted from a list
get lineOffset(the short name of the target,field "Groups List")
delete line it of field "Groups List"
pass deleteGroup
end deleteGroup
If your asking something else or something more specific, feel free to elaborate.
Re: A group that can delete itself
Posted: Tue Feb 19, 2019 11:32 am
by Klaus
Hi Kaveh,
as an admin I can assure there are only humans here in this forum!
Problem:
You cannot delete an object whose script is currently being executed, so the trick is to "outsource" the actual "delete" command!
Do like this:
Button script
Code: Select all
on mouseup
put the long ID of the owner of me into yowsayowsayowsa
send "delete_it yowsayowsayowsa" to this cd in 1
end mouseup
When using THE LONG ID we do not need to specify the type of object (button, field, group, whatever).
Card script
Code: Select all
command delete_it tObject
delete tObject
end delete_it
Tested and works!
Best
Klaus
Re: A group that can delete itself
Posted: Tue Feb 19, 2019 11:47 am
by bogs
Klaus wrote: ↑Tue Feb 19, 2019 11:32 am
as an admin I can assure there are only humans here in this forum!
I don't remember seeing the checkbox for sprites when I signed up

Re: A group that can delete itself
Posted: Tue Feb 19, 2019 11:49 am
by Klaus
I KNEW you are a fairy queen!

Re: A group that can delete itself
Posted: Tue Feb 19, 2019 11:54 am
by bogs

- We ain't all pixies :P
- Selection_004.png (8.1 KiB) Viewed 6158 times
Never saw the movie "Tooth Fairy" eh?
This is a poster for the film Tooth Fairy. The poster art copyright is believed to belong to the distributor of the film, 20th Century Fox, the publisher of the film or the graphic artist.
Re: A group that can delete itself
Posted: Tue Feb 19, 2019 12:03 pm
by Klaus
bogs wrote: ↑Tue Feb 19, 2019 11:54 am
Never saw the movie "Tooth Fairy" eh?
Sure I did, with my friend Dwayne and the lovely Julie Andrews!

Re: A group that can delete itself
Posted: Tue Feb 19, 2019 12:42 pm
by kaveh1000
Thank you Klaus. You are still a god when viewed from down here.
Works nicely. My error was putting the delete handler in the group.
Re: A group that can delete itself
Posted: Tue Feb 19, 2019 1:54 pm
by Klaus
Hi Kaveh,
this is just 20 years of experience in working with Livecode and its ancestors (MetaCard, Revolution). And the first three years without internet access (yes, those were the days), so just try & error, hard but highly effective!
Best
Klaus
Re: A group that can delete itself
Posted: Tue Feb 19, 2019 2:10 pm
by kaveh1000

I started with Hypercard beta, before Apple had a manual. Been dabbling ever since. The love never goes away...

Re: A group that can delete itself
Posted: Tue Feb 19, 2019 2:52 pm
by bogs
Meh, you spoiled brats! InterWebz, PSHAW

Manuals... we used hieroglyphs!!
When
I started, all we had was an
Antikythera device, a
chisel, and an
Abacus, and we
LIKED it that way
I can tell you many was the time we had to walk to the temple in 25 cubits of snow, UPHILL both ways, just to attend the ritual sacrifices...
