Re: How to get the index of an item in a list
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