Re: Address Book: Delete Person
Re: Address Book: Delete Person
- Subject: Re: Address Book: Delete Person
- From: Christopher Nebel <email@hidden>
- Date: Thu, 15 Jan 2004 23:25:19 -0800
On Jan 15, 2004, at 11:21 AM, Paul Berkowitz wrote:
On 1/15/04 10:00 AM, "JimMain" <email@hidden> wrote:
I'm trying to delete certain people from the address book. I've
deleted
groups successfully, but haven't had any luck with people.
This runs without error, but doesn't delete any entries:
tell application "Address Book"
activate
delete (people whose (label of AIM handles) contains "%X")
end tell
Well, that one doesn't add up. AIM Handles are elements, not
properties: you can have a contact with 2, or 5, or 25 different AIM
Handles, and each AIM Handle might well have a different label. That's
why you can only use 'whose' clauses on properties of elements, not
elements of elements.
As has been discussed before, you most certainly can apply "whose"
clauses to elements. That is, there's nothing in AppleScript that
prevents it. (An application might not support it correctly, in which
case it's got a bug.) As it happens, Address Book is doing something
with that command, but not quite what you wanted. What that command
actually does is delete everyone with an AIM Handle whose label is
*exactly* "%X". (For each person, get the labels of all their AIM
handles, which form a list. Does that list contain the value "%X"?)
If I make someone who matches, they get deleted.
From your other attempts, you seem to want everyone with an AIM handle
whose label *contains* "%X". That's harder, and I don't think you can
do it in one line, given the constraints on what "whose" clauses can
express. (In particular, you can't call functions, such as "exists".)
Your loop is the right direction, though I'd have expressed the test
something like this:
repeat with p in every person
if exists (first AIM Handle of p whose label contains "%X") then
delete p
end
However, I then find the same thing you did: although the "delete"
command is in fact sent, p doesn't get deleted. For this, I am at a
loss, and will file a bug. In the meantime, this works:
repeat with p from 1 to (count people)
if exists (first AIM Handle of person p whose label contains "%X")
then delete person p
end repeat
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.