Re: Coordinating lists
Re: Coordinating lists
- Subject: Re: Coordinating lists
- From: has <email@hidden>
- Date: Wed, 3 Apr 2002 10:42:52 +0100
Matthew Stuckwisch wrote:
[snip script]
>
(now watch, in ten seconds upon
>
sending this mail I'll already have gotten a response "oh just use [input
>
command] to find the offset of an entry in a list" :P )
Oh, too cynical - it'll take at least fifteen.:)
There's no magical osax command in the standard suite to sprinkle upon this
problem. Not that I can see how that'd make things any easier: good ol'
fashioned vanilla code's plenty good for this sort of thing.
You can tidy your findOffset() handler as follows:
======================================================================
on findOffset(theList, theEntry)
repeat with repVar from 1 to theList's length
if (item repVar of theList) = theEntry then return repVar
end repeat
error "Item '" & theEntry & "' not found."
end findOffset
======================================================================
And boost its speed across larger lists by using "That Technique" too:
======================================================================
on findOffset(theList, theEntry)
script
property _theList : theList
end script
tell result
repeat with repVar from 1 to theList's length
if (item repVar of its _theList) = theEntry then return
[NO-BREAK]repVar
end repeat
end tell
error "Item '" & theEntry & "' not found."
end findOffset
======================================================================
Cheers,
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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.