Re: The Need for Speed: Finding Entourage contacts by display name or nickname
Re: The Need for Speed: Finding Entourage contacts by display name or nickname
- Subject: Re: The Need for Speed: Finding Entourage contacts by display name or nickname
- From: Jolly Roger <email@hidden>
- Date: Fri, 22 Jun 2001 17:25:17 -0500
On 6/22/2001 11:46 AM, "Paul Berkowitz" <email@hidden> wrote:
>
On 6/22/01 8:11 AM, "Jolly Roger" <email@hidden> wrote:
>
>
> Hi folks,
>
>
>
> Me again with another silly Entourage question... =)
>
>
Except you're quicker to acknowledge the replies that don't help, than the
>
ones that do.. ;-) (I hope the last 'email address' reply worked OK in the
>
end?)
Sorry about that, Paul. I'm so busy sometimes I barely have time to post
questions much less report my results! I'll try to do better in the future.
Yes, it did work; but because I wanted to also define the default email
address, I ended up setting the address on a separate line so that I had a
reference to it to use in the "default email address" line.
>
> The following script searches through the Entourage contact list looking for
>
> a contact that has the display name or nickname specified. This is
>
> dreadfully slow in comparison to the built-in Entourage "find" utility, which
>
> only searches for email addresses.
>
>
>
> Anyone have any suggestions on what I might do to speed this up?
>
>
Entourage implements 'whose' filters, like the Finder does, which are
>
extremely fast. (That's what 'satisfying a test' means in the Dictionary:
>
'implements 'whose clauses' for this element.) They are implemented for
>
every element of every class in Entourage - it's been very thorough - except
>
they forgot to implement it for 'category' of contact, which is a nuisance.
>
That will be fixed.
Good to hear! I'll be making use of this stuff. :)
>
Also, you may not be aware that you can get 'name' of contact: it's not a
>
property of contact but rather that, as an element of the application, it
>
can be specified 'by name' (see 'application' , element 'contact' in the
>
Dictionary). So you don't need to do that 'first name & " " & last name'
>
business, which would actually require a lot more checking in case it had
>
been entered just as first name or last name, with the other blank, or as a
>
nickname.
(snip)
This is what I ended up with:
on FindContactByDisplayName(displayName)
if gTiming then set startTime to (the ticks) -- Jon's Commands
set foundContact to {}
try
tell application "Microsoft Entourage"
set foundContact to the first contact ,
whose name contains displayName ,
or nickname contains displayName
end tell
end try
-- uses Jon's Commands
log ("elapsed time: " & ((the ticks) - startTime & " ticks"))
return foundContact
end FindContactByDisplayName
This method can do more accurate searches and has reduced my search time
from a whopping 708 ticks (11.8 seconds) to a measly 38 ticks (a little more
than half a second)! This is a fantastic performance increase.
Thank both of you very much for your help!
JR