Re: Get position of item in list
Re: Get position of item in list
- Subject: Re: Get position of item in list
- From: Joseph Weaks <email@hidden>
- Date: Tue, 24 Jun 2003 21:53:31 -0500
These have all been some very wordy solutions. How does one gauge when the
simple repeat I'm using is not efficient? A list of 20 items, 50 items,
100 items? Maximum length of each string in the list of 50 characters,
100 characters, 500 characters?
on getPosition(theString, theList)
if theString is in theList then
repeat with x from 1 to (count text items of theList)
if (text item x of theList) starts with theString then
return x
end if
end repeat
else
return 0
end if
end getPosition
getPosition("for", {"wan", "too", "tree", "for"})
-- 4
("Starts with" suits my current purpose, only returning the first match.)
Cheers,
Joe Weaks
_______________________________________________
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.