Thanks very much, Paul. The script does just what I wanted, as far as it goes. Now that I’m getting so good at AppleScripts :), I’d like to add a few things a little more advanced.It's really time for you to study the AppleScript Language Guide and/or a book like Danny Goodman's AppleScript Handbook. There's nothing frightening about lists. It's a little confusing that Entourage has two different things called 'category': one is a class, and is the 'category' you see when you Edit categories, or assign them. They are elements of the application. so there's a 'category "Family"' and there's a 'category "Friends"' - with meaning across the application. Then there's the 'category' property of ca contact, an event, a task, etc. That has to be a list since each object can have more than one category, right? The items of this list are the application categories - category "Family", category "Friends", etc. it's unfortunate that the property is also called category': it could have been called 'category list'.
I’d like to update the Notes, only if the category is “family” or “friends”. But I see that category is a list. So I’m afraid that I just can’t say “if category = ‘family’ or ‘friends’.
List have items. But in AppleScript, do check what anything contains, you need the same class on both sides of the operation. That's why you have to read up on this stuff: learn about lists and the 'contains' operator. So to check if a list contains an item, you need to put the item in a 1-item list.
tell c
set theCats to its category
if theCats contains {category "Friends"} or theCats contains {category "Family"} then
--continue
No it isn't, because you want to put them into a string, and they're a list. Presuming you want them on one line, separated by commas and a space:
Similarly, if “children” are listed, I’d like to show them in my Notes, but again it is probably not as simple as “set theNotes to get its children”.
tell c
set theChildren to its children
if theChildren � {} then -- not an empty list
set AppleScript's text item delimiters to {", "}
set theChildren to theChildren as string -- turns the list into text with the items separated by ", "
set AppleScript's text item delimiters to {""} -- always restore them!!
set theNotes to theNotes & "Children: " & theChildren & return
end if
Read up on AppleScript's text item delimiters, a scripter's best friend.
You can set it easily as a 'long date': "Friday, August 1, 2002" or "Friday, August 1, 2002 9:37:48 PM" . to turn it into a short date requires a more complicated handler of 20 or so lines, plus another handler of 15 or so lines to get the user's date format. (If it's just for yourself, you won't have to do that.) You can find some in several of my scripts. Learn about dates, date strings and date as string. Long date:
And, can I set Custom date 1, which is text, to modification date, which is type date. Or is a translation required?
set modDate to its modification date
set modDate to date string of modDate -- or set modate to moddate as string -- (includes the time)
set its custom date one to modDate
And finally, if a business address is present, I’d like to show it in the Notes as a secondary address. But how do I qualify address, city, etc. so that I’m not referring to the home address?It's all in the dictionary, peter. You'll see 'business address' as a property of type 'postal address', and then after contact, you'll see 'postal address' as a class.
tell c
set workAddress to its business address
set {workStreet, workCity, workState, workZip, workCountry} to workAddress's (street, city state, zip, country)
if result � {"", "", "", "", ""} then
set workAddress to "Work Address: "
if workStreet � "" then set workAddress to workAddress & workStreet & ", "
if workCity � "" then set workAddress to workAddress & workCity &
if workState � "" then set workAddress to workAddress & ", " & workState
if workZip � "" then set workAddress to workAddress & " " & workZip
if workCountry � "" then set workAddress to workAddress & ", " & workCountry
set theNotes to theNotes & workAddress & return
end if
Or throw in a few returns.
Thanks in advance for your trouble.
OK. Why don't you start reading an AppleScript language book now?
--
Paul Berkowitz
