Re: Address Book: why doesn't this work?
Re: Address Book: why doesn't this work?
- Subject: Re: Address Book: why doesn't this work?
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 19 Jan 2006 17:48:13 -0800
- Thread-topic: Address Book: why doesn't this work?
Title: Re: Address Book: why doesn't this work?
On 1/19/06 5:25 PM, "Rob Lewis" <email@hidden> wrote:
tell application "Address Book" --ready to create a new Address Book record
set ABpersref to (make new person with properties ¬
{first name:ABfname, middle name:ABmname, last name:ABlname, job title:ABtitle, department:ABdept, organization:ABco, note:ABnote, company:false})
tell person ABpersref
make new address with properties {label:"Work Address", city:ABwkcity, country:ABwkctry, state:ABwkstate, street:ABwkadr, zip:ABwkzip}
make new address with properties {label:"Home Address", city:ABhmcity, country:ABhmctry, state:ABhmstate, street:ABhmadr, zip:ABhmzip}
make new phone with properties {label:"Work", value:ABwkphone}
make new phone with properties {label:"Home", value:ABhmphone}
make new phone with properties {label:"Fax", value:ABfaxphone}
if length of name = 0 then set company to true --"company" is a boolean; we'll set true if composite name is empty
end tell --person ABpersref
end tell --Address Book
When run, it highlights the first "make new address" statement with this error message:
Address Book got an error: Can't make person (person id "2F7657BA-AFDC-4A0F-AE0F-083FF023C1FF:ABPerson") into type reference.
Because you set the variable ABpersref to be a person, and then later you use it as if it were the name of a person:
person "Somebody OrOther"
is the way to refer to a person by name. To use a variable that is already defined to be a person, just use the variable:
tell ABpersref
make new address -- etc.
NOT
tell person tell ABpersref
make new address -- etc.
which raises that exact error. You can even see from the error that it knows that the variable is a person specified by ID; it's confused, rightly, by the second, unnecessary and faulty 'person' specifier before it.
(By the way, in previous OS's you'd have to make new address 'at the end of addresses': I believe that was rendered unnecessary in either panther or Tiger, but you might want to check it in Panther to make sure you don't need it.)
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden