Re: Get position of item in list
Re: Get position of item in list
- Subject: Re: Get position of item in list
- From: Paul Skinner <email@hidden>
- Date: Wed, 25 Jun 2003 09:11:41 -0400
On Tuesday, June 24, 2003, at 10:53 PM, Joseph Weaks wrote:
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
Don't go there. just write the most efficient handler you can and use
it consistently.
ps
_______________________________________________
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.