• 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: How to get the index of an item in a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the index of an item in a list


  • Subject: Re: How to get the index of an item in a list
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 25 Jun 2001 02:38:14 -0700

On 6/25/01 12:45 AM, "Greg Strange" <email@hidden> wrote:

> I have tried this (I'm heavily paraphrasing):
>
> display dialog "Which one?" default answer "" buttons {"Get Description",
> "Cancel"}
> set yourDesc to the text returned of the result
> if yourDesc is "Get Description" then
> set theIndex to the index of yourDesc in theFirstList
> set theAnswer to item theIndex of theSecondList
>
> This does not get me what I want. It says that it "can't get yourDesc of
> {"firstItem", "secondItem", "thirdItem"}"
>
> I can see where I could loop through with a counter and get it but isn't
> there a better way?

Not in pure AppleScript there isn't. You can use Akua Sweets;

set theIndex to item 1 of (collect items of theFirstList that match
yourDesc)

which is a lot easier to script, but the repeat loop in pure AppleScript is
actually faster OMM any time I've tested since about OS 8.6 or 9.0.


--
Paul Berkowitz


References: 
 >How to get the index of an item in a list (From: Greg Strange <email@hidden>)

  • Prev by Date: Re: Finder: Delete files
  • Next by Date: Re: How to get the index of an item in a list
  • Previous by thread: Re: How to get the index of an item in a list
  • Next by thread: Re: How to get the index of an item in a list
  • Index(es):
    • Date
    • Thread