Re: Properties within Properties - Scripting Address book
Re: Properties within Properties - Scripting Address book
- Subject: Re: Properties within Properties - Scripting Address book
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 13 Sep 2005 23:45:23 -0700
- Thread-topic: Properties within Properties - Scripting Address book
Title: Re: Properties within Properties - Scripting Address book
On 9/13/05 6:47 PM, "chet kelley" <email@hidden> wrote:
I was trying to write an Applescript for my wife that would help her enter a long list of people into address book. The problem I was having was that the properties "street", "city", "state" and "zip" are contained within "address" so the statement,
make new person with properties {organization: "drama", city: "Miami", state:"Fl"}
doesn't work because city and state aren't properties of the person class. So I tried
make new person with properties {organization: "drama", address:{city: "Miami", state:"Fl"}}
which applescript compiled without complaints, but didn't work (only the organization was entered into the new person record.
I tried taking the long route and trying
make new person with properties {organization: "drama"}
set city of new person to "Miami"
set state of new person to "Fl"
but that didn't input the info either.
Any ideas?
1. Learn AppleScript. I recommend Matt Neuburg's "AppleScript: The Definitive Guide" (O'Reilly).
2. You're aware that city and state aren't properties of person, but you still think 'address' is. Why? The dictionary states quite clearly that that address is an element, not a property, of person. That's because person can have o to infinite addresses. Properties are attributes you can (and must) have only one of. You cannot set 'address' to anything, since there's nothing to set. What would you then do to 'set' a second address, then? You have to 'make new address' at the person, just like you make a new person (which is an element of the application: same syntax applies).
3. In Cocoa apps, you have to make elements at the beginning or end (Carbon apps aren't so fussy).
4, To be able to make elements at the person after making it, you need to set a variable to the result of making it, in order to have something to make elements at. any variable will do. Here's 'p'. You make it 'with properties (city: , state: }' , etc. as usual.
5. Addresses also have a label property. If you don't set it it will come out as 'other', the default. This one looks like a 'work' label.
6. In order to get anything to register and display in Address Book, short of clicking manually somewhere else, or quitting, you need to end with 'save addressbook'. (This is ridiculous, but true.)
tell app "Address Book"
set p to make new person with properties {organization: "drama". company:true} -- no name, so let the organization behave as name
make new address at p with properties {label:"work", city:"Miami", state:"FL"}
save addressbook
end tell
(P.S. Surely there's more to its address than "Miami, FL"? But you get the idea.)
--
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