• 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: Determining item number matching "x" in a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining item number matching "x" in a list


  • Subject: Re: Determining item number matching "x" in a list
  • From: Emmanuel <email@hidden>
  • Date: Wed, 12 Mar 2003 00:31:57 +0100

At 3:10 PM -0500 11/03/03, Steve Cunningham wrote:
I wonder if there is some trivial way to do this without writing a repeat
loop that cycles through every value of the list looking for a match:

I have a list, theList = {"a","b","c","etc"} and I want to know the item
number of the item that matches a variable x. I need something like

"get the item number of x in theList"

which returns a if x = "a", 2 if x = "b" etc.

Did I miss a page in the manual :-)

You did not, like Paul confirmed.

The loop method may be slow if your script has to perform that task often. For a faster (yet, less direct) method, convert the list into a string, use the Regular Expressions to locate the variable, and then again to evaluate the index of the match.

Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Determining item number matching "x" in a list
      • From: John Delacour <email@hidden>
References: 
 >Determining item number matching "x" in a list (From: Steve Cunningham <email@hidden>)

  • Prev by Date: Re: QXP5 and Layers
  • Next by Date: Re: Getting Multiple Returns From A Dialog
  • Previous by thread: Re: Determining item number matching "x" in a list
  • Next by thread: Re: Determining item number matching "x" in a list
  • Index(es):
    • Date
    • Thread