Re: Delete an item in a list ?
Re: Delete an item in a list ?
- Subject: Re: Delete an item in a list ?
- From: Bill White <email@hidden>
- Date: Fri, 12 Nov 2004 10:51:00 -0500
On 11/12/04 10:37 AM, Studio G sarl <email@hidden> wrote:
> May be it's very easy, but can someone tell me how to delete an item in a
> list ?
>
> Set ma_liste to {"un", "deux", "trois", "quatre"}
> Return length of ma_liste
> -> 4
>
> Set ma_liste to {"un", "deux", "trois", "quatre"}
> Delete item 2 of ma_liste
> Return length of ma_liste
> -> 4
Without a scripting addition, you'll have to dig through the list manually.
Try this:
set ma_liste to {"un", "deux", "trois", "quatre"}
set new_list to {}
repeat with i from 1 to length of ma_liste
if i is not 2 then copy item i of ma_liste to end of new_list
end repeat
new_list --> {"un", "trois", "quatre"}
length of new_list -->3
Note: you can also roll the removal into a handler to remove a different
list entry:
set ma_liste to {"un", "deux", "trois", "quatre"}
removeItemFromList(2, ma_liste)
on removeItemFromList(n, this_list)
set new_list to {}
repeat with i from 1 to length of this_list
if i is not n then copy item i of this_list to end of new_list
end repeat
return new_list
end removeItemFromList
HTH,
Bill
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden