• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: The Need for Speed: Finding Entourage contacts by display name or nickname
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Paul Berkowitz <email@hidden>
  • Date: Fri, 22 Jun 2001 12:43:13 -0700

Sorry if you get two copies. I sent this about 3 hours ago but it hasn't
appeared yet. (Slightly cut down here.)


On 6/22/01 8:11 AM, "Jolly Roger" <email@hidden> wrote:

>
> 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.

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.

set theContacts to every contact whose name is "Jolly Roger" or nickname
is "Jolly Roger"

and check for duplicates. That will do what your whole script below does, a
lot faster, with no repeat loop, plus check for nickname, all in one shot.
If you don't care about duplicates then

try
set theContact to the first contact whose name is "Jolly Roger" or
nickname is "Jolly Roger"
on error
set theContact to make new contact with properties {first
name:"Jolly", last name:"Roger"}
end try

will do the job, including the possibility that someone, somewhere, knows
your real name and put in "Jolly Roger" as a nickname.

HTH.

--
Paul Berkowitz

>
> -- start script
> my FindContactByDisplayName("JollyRoger")
>
> on FindContactByDisplayName(displayName)
> set startTime to (the ticks) -- Jon's Commands
>
> set foundContact to {}
> tell application "Microsoft Entourage"
> repeat with c from 1 to the count of the contacts
> if (displayName = (contact c's first name & " " & contact c's
> last name)) or (displayName = contact c's nickname) then
> set foundContact to contact c
> exit repeat
> end if
> end repeat
> end tell
>
> -- uses Jon's Commands
> log ("elapsed time: " & ((the ticks) - startTime & " ticks"))
>
> return foundContact
> end FindContactByDisplayName
> -- end script


References: 
 >The Need for Speed: Finding Entourage contacts by display name or nickname (From: Jolly Roger <email@hidden>)

  • Prev by Date: Re: applescript-users digest, Vol 2 #790 - 14 msgs
  • Next by Date: Ping from Applescript with no app?
  • Previous by thread: Re: The Need for Speed: Finding Entourage contacts by display name or nickname
  • Next by thread: Re: Creating Entourage contacts (revisited)
  • Index(es):
    • Date
    • Thread