How do I delete cloned images with the same name all at once?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
The property “name” refers to more than “ticket”, it also includes the description of the control, in your case the name will be “image ticket”.
You also will need to count down from the number of images in order to delete all of them, otherwise you will run into a situation where x is higher than the number of images still on your card
Use short name instead of name, this will script  will work:

on mouseUp
put the number of images of this card into tImages
repeat with x = tImages down to 1
  if the short name of image x = “ticket” then  
     delete image x
  end if
end repeat
end mouseUp

> 17. jan. 2018 kl. 23:25 skrev William de Smet via use-livecode <[hidden email]>:
>
> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
On 01/17/2018 02:42 PM, Tore Nilsen via use-livecode wrote:

> Use short name instead of name, this will script  will work:

Additionally, the way I deal with this is to create a group, then create
the control *in the group*. That way all I have to do is delete the
group and all the child controls are gone.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
@Tore and @Mark

Thanks!
Works fine now.


greetings,

William



2018-01-18 0:13 GMT+01:00 Mark Wieder via use-livecode <
[hidden email]>:

> On 01/17/2018 02:42 PM, Tore Nilsen via use-livecode wrote:
>
> Use short name instead of name, this will script  will work:
>>
>
> Additionally, the way I deal with this is to create a group, then create
> the control *in the group*. That way all I have to do is delete the group
> and all the child controls are gone.
>
> --
>  Mark Wieder
>  [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
In reply to this post by dunbarx via use-livecode
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 <
[hidden email]> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
In reply to this post by dunbarx via use-livecode
Rather use the long id. Just the id means your statement resolves to "delete 456" or some such thing.

The other thing you can do is rename the clones as soon as you create them so you can reference them later.

Bob S

> On Jan 17, 2018, at 14:42 , Tore Nilsen via use-livecode <[hidden email]> wrote:
>
> The property “name” refers to more than “ticket”, it also includes the description of the control, in your case the name will be “image ticket”.
> You also will need to count down from the number of images in order to delete all of them, otherwise you will run into a situation where x is higher than the number of images still on your card
> Use short name instead of name, this will script  will work:
>
> on mouseUp
> put the number of images of this card into tImages
> repeat with x = tImages down to 1
>  if the short name of image x = “ticket” then  
>     delete image x
>  end if
> end repeat
> end mouseUp
>
>> 17. jan. 2018 kl. 23:25 skrev William de Smet via use-livecode <[hidden email]>:
>>
>> 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
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
In reply to this post by dunbarx via use-livecode
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 <[hidden email]>:
>
> 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 <
> [hidden email]> 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
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How do I delete cloned images with the same name all at once?

dunbarx via use-livecode
Correction of previous script:

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
end deleteImage

> 18. jan. 2018 kl. 17:32 skrev Tore Nilsen via use-livecode <[hidden email]>:
>
> 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

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode