• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Delete an item in a list ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Delete an item in a list ?
      • From: Emmanuel <email@hidden>
References: 
 >Delete an item in a list ? (From: Studio G sarl <email@hidden>)

  • Prev by Date: Delete an item in a list ?
  • Next by Date: Re: Delete an item in a list ?
  • Previous by thread: Delete an item in a list ?
  • Next by thread: Re: Delete an item in a list ?
  • Index(es):
    • Date
    • Thread