• 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: Andy Wylie <email@hidden>
  • Date: Tue, 26 Jun 2001 18:37:44 +1200

on 25/6/01 7:45 pm, Greg Strange at email@hidden wrote:

> I have two lists like this:
>
> set theFirstList to {"firstItem", "secondItem", "thirdItem"}
> set theSecondList to {"The first name is great","The second item is
> unoriginal", "This is silly."}
>
> I want to allow the user to pick the name of the item in the first list and
> get the correct item from the second list.
>
> I can see where I could loop through with a counter and get it but isn't
> there a better way?
>
I don't better know about better but it's a way I've not seen before...

set alist to {"A: firstItem", "B: secondItem", "C: thirdItem"}
set blist to {"The first name is great", "The second item is unoriginal",
"This is silly."}
set cStr to "ABC"

set x to character 1 of ("" & (choose from list alist))
if result is false then return
blist's item (offset of x in cStr)
-- "This is silly."

___________loose lists, sync $#!%s__ Andy


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

  • Prev by Date: Re: OS X Scripting Documentation
  • Next by Date: Re: Script for Entourage emails -> Filemaker for easy searching
  • Previous by thread: Re: How to get the index of an item in a list
  • Next by thread: which version AS?
  • Index(es):
    • Date
    • Thread