Index from list
Index from list
- Subject: Index from list
- From: Pier Kuipers <email@hidden>
- Date: Mon, 19 Feb 2001 12:01:15 +0000
I am trying to find a "clean and quick" way to find out the index of
any item in an unordered list with Vanilla Applescript. Below is the
snippet that I've come up with:
on getListIndex(theItem, theList)
set x to count theList
set p to 1
repeat with i from 1 to x
if theItem = item p of theList then
return p
exit repeat
else
set p to p + 1
end if
end repeat
return p
end getListIndex
set myList to {"Hello", "My Name", "is", "Pier", "Kuipers"}
set myItem to "Pier"
getListIndex(myItem, myList)
-- returns 4 in this case
Is there a neater, or quicker, way to do this? Will this script
result in slow performance if the list is very long? Any advice
greatly appreciated.
Pier.
--
Pier Kuipers
Visual ID
* the Media Asset Management solution *
2 Whitefriars
Aungier Street
Dublin 2
Tel. +353 1 476 7059
Mobile +353 87 294 3063
Fax +353 1 478 1366
ISDN +353 1 602 0754
http://www.visualid.com