Re: Remove a Person from Address Book
Re: Remove a Person from Address Book
- Subject: Re: Remove a Person from Address Book
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 12 Mar 2003 18:21:13 -0800
Yes, there is such a command:
save addressbook
It's very peculiar for a database app, but you do have to do this to see the
changes immediately. If you're creating or modifying many contacts, you
might want to do it along the way. in the rather odd scripts that are
supplied by Apple (check "Mail Scripts" in the Scripts menu - God knows why
"Mail" since it's Address Book), the person who wrote the Address Book
import scripts does a 'save address book' after every 3 contacts. It may be
that they want to save data in case of crashing - I don't know - or if you
wait until importing 500 contacts there may be too much to save all at once.
'save addressbook' also takes time to execute - maybe once every 10 contacts
and again at the very end, outside the repeat loop - would be sufficient.
--
Paul Berkowitz
>
From: Andrew Oliver <email@hidden>
>
Date: Wed, 12 Mar 2003 12:57:54 -0800
>
To: Darwin Zins <email@hidden>, <email@hidden>
>
Subject: Re: Remove a Person from Address Book
>
>
Check again.
>
>
When I tried it, it did delete the person, but didn't refresh the name list
>
to reflect the change.
>
>
Selecting a different group, or closing/reopening the window refreshes the
>
list and shows your changes.
>
>
I don't see anything in the Address Book dictionary that will refresh the
>
name list. Sounds like a bug to me.
>
>
Andrew
>
:)
>
>
On 3/12/03 11:19 AM, "Darwin Zins" <email@hidden> wrote:
>
>
> Hmm. I just tried that, but it doesn't actually delete the contact
>
> from the Address Book. It doesn't error out or anything, it just
>
> doesn't actually delete the contact.
>
>
>
> Darwin
>
>
>
> On Wednesday, March 12, 2003, at 12:45 PM, Andrew Oliver wrote:
>
>
>
>> You're calling:
>
>>
>
>>> remove aCard
>
>>
>
>> The dictionary reference for 'remove' states:
>
>>
>
>> remove: Remove a child object.
>
>> remove reference -- the object for the command
>
>> from reference -- where to remove this child from.
>
>>
>
>> So if you use 'remove' you need to also be specific about where you
>
>> want to
>
>> remove it from. I have no idea what the appropriate values would be.
>
>>
>
>> However, this appears to work for me:
>
>>
>
>> delete aCard
>
>>
>
>> Which seems to solve the problem.
>
>>
>
>> On 3/12/03 9:47 AM, "Darwin Zins" <email@hidden> wrote:
>
>>
>
>>> I have this code:
>
>>>
>
>>> -- Remove any Entries in Apple Address Book that are not in Zaurus
>
>>> Address Book
>
>>> tell application "Address Book"
>
>>> repeat with aCard in every person
>
>>> set found_in_z to false
>
>>> set a_first_name to first name of aCard as string
>
>>> set a_last_name to last name of aCard as string
>
>>> repeat with anItem in XML contents of theXML
>
>>> if XML tag of anItem is equal to "Contacts" then
>
>>> repeat with zCard in XML contents of anItem
>
>>> try
>
>>> set z_first_name to |FirstName| of XML attributes of zCard as
>
>>> string
>
>>> on error
>
>>> set z_first_name to ""
>
>>> end try
>
>>>
>
>>> try
>
>>> set z_last_name to |LastName| of XML attributes of zCard as
>
>>> string
>
>>> on error
>
>>> set z_last_name to ""
>
>>> end try
>
>>> if a_first_name = z_first_name and a_last_name = z_last_name then
>
>>> set found_in_z to true
>
>>> exit repeat
>
>>> end if
>
>>> end repeat
>
>>> end if
>
>>> end repeat
>
>>> if found_in_z is false then
>
>>> tell me to display dialog "Removing " & a_first_name & " " &
>
>>> a_last_name
>
>>> remove aCard
>
>>> end if
>
>>> end repeat
>
>>>
>
>>> When it runs I get this error: "Address Book got an error:
>
>>> NSCannotCreateScriptCommandError"
>
>>>
>
>>> How do I tell the Address Book to delete this person?
>
>>>
>
>>> Thanks,
>
>>>
>
>>> Darwin
>
>>> _______________________________________________
>
>>> 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.
>
> _______________________________________________
>
> 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.
>
_______________________________________________
>
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.
_______________________________________________
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.