Re: Efficiently using whose on Address Book users
Re: Efficiently using whose on Address Book users
- Subject: Re: Efficiently using whose on Address Book users
- From: Michael Terry <email@hidden>
- Date: Sun, 22 Feb 2004 22:07:37 -0800
On Feb 22, 2004, at 5:44 PM, Michael Terry wrote:
I'm writing a script that I want to act differently based on whether
a user is in the Address Book. Works fine when I search for "records
whose name is...". But as mentioned earlier this month, "records
whose email is..." doesn't work because email returns a list rather
than a string.
I have this solved with a script that recurses through the entire
address book, but as you might expect, response time is now
measurable in 10s of seconds where it was previously instantaneous.
There is clearly some interapplication communication that does this
better -- a rule in Mail.app to set the color of a message from
someone in my Address Book happens immediately.
Is there a way of constructing a whose clause that comes up with
this? Barring that, at least a faster way of figuring out if email X
appears in the address book?
_______________________________________________
Here's one way:
repeat with address in {"email@hidden", "email@hidden"}
tell app "Address Book" to tell value of emails of people
|address| is in (it as Unicode text)
end tell
end repeat
If, as I read what you wrote, you just need to find out whether an
address is already in Address Book, my current favorite for this is
(borrowing Paul's direct method for seeing whether any records match):
on isInBook(addy)
tell application "Address Book" to try
return (first person where value of emails of it contains addy) /= 0
end try
return false
end isInBook
isInBook("email@hidden")
Could you clarify if any of us are on the right track?
Mike
_______________________________________________
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.