Re: Address Book->check for existing record before adding
Re: Address Book->check for existing record before adding
- Subject: Re: Address Book->check for existing record before adding
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 17 Oct 2003 15:37:10 -0700
On 10/17/03 1:31 PM, "Rob Jorgensen" <email@hidden> wrote:
>
At 12:39 PM -0700 10/17/03, Matthew Galaher wrote:
>
> I am working on a script that so far uses a loop through every record
>
> to check that I am not making a duplicate record by adding a new
>
> contact through a script. This is mind numbingly slow. I first tried
>
> something like "person whose email is "email@hidden" but I could not get
>
> this to work. What I have so far follows, but I'm wondering if any one
>
> has a suggestion for better i.e. faster way to approach this.
>
> Thanks in advance.
>
>
Maybe this will help:
>
>
tell application "Address Book"
>
id of every person where value of emails contains "email@hidden"
>
end tell
(If using 'where' rather than 'whose' it's a good idea to include 'its':
id of every person where value of its emails contains "email@hidden"
Fortunately AppleScript does the coercion of string to single-item list
{"email@hidden"} fro you.)
You would also need 'value' here:
repeat with anEmailAddress in emailList
if emailAddress is equal to (value of anEmailAddress)
then
display dialog emailAddress & " and " & (value of
anEmailAddress) & " are the same"
end if
If it weren't 'value' you'd never get an x in 'repeat with x in list' to be
equal to some value - it's always 'item 1 of {a, b, c}'. You can save a lot
of anguish by using the type of repeat loop that always evaluates values:
repeat with i from 1 to (count emailList)
set anEmailAddress to item i of emailList
if emailAddress is equal to (value of anEmailAddress)
then
display dialog emailAddress & " and " & (value of
anEmailAddress) & " are the same"
end if
although in this case it doesn't matter since 'value of' will get the actual
value in any case.
--
Paul Berkowitz
_______________________________________________
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.