You do need to count down to 1, otherwise the counter x will become greater than the number of images you have on the card, halfway through the repeat loop. There is also no need to get the ID (neither the long or short ID) as you can simply refer to the image by its number (the counter x). The best solution is the suggestion from Mark Wieder, to place the cloned images in a group and just delte the whole group in one go. Then there is no need for looping or checking names or IDs.
If for any reason you cannot place the images in a group, you should take the advice from Bob Sneidar and rename each clone as you create them. The easiest way is to add a number to the name, storing the latest number in a variabel if the clones are not made within a repeat lopp with a counter. This script will then work: local sImageNum on cloneImage clone image “ticket” add 1 to sImageNum set name of last image to “ticket” & sImageNum end cloneImage on deleteImage put the number of images of this card into tImages repeat with x = sImages down to 1 if last char of the short name of image x is an integer then — you will then keep the image you use as basis for the clones delete image x end if end repeat repeat with x Best regards Tore Nilsen > 18. jan. 2018 kl. 12:08 skrev Lagi Pittas via use-livecode > <use-livecode@lists.runrev.com>: > > Hi William > > First off - the send is outside the repeat but I assume that's an error in > transcribing to the email. > > but this works > > on mouseUp > local gone, x > repeat with x= 1 to the number of images of this card > if the short name of image x is "ticket" then > put the id of image x into gone > delete image ID gone > end if > end repeat > end mouseUp > > the name gives "image ticket" so it will never succeed. > > Lagi > > > On 17 January 2018 at 22:25, William de Smet via use-livecode < > use-livecode@lists.runrev.com> wrote: > >> Hi there, >> >> I have several cloned images and all have the same name: ticket. >> Of course there ID is different. >> On close card I want to delete them. >> How do I delete them all at once? >> Wat is wrong with this code? >> >> on mouseup >> repeat with x= 1 to the number of images of this card >> if the name of image x is "ticket" then put the ID of image x into GONE >> end repeat >> send ("delete GONE") to me in 0 ticks >> end mouseup >> >> >> >> >> greetings, >> >> William >> _______________________________________________ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your >> subscription preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode >> > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode