Adding phone number and address details to new card in Address Book

This should be easy but I have tried and tried and I have looked everywhere for clues! Please help!!

-- CREATING THE NEW MEMBER
repeat
	set theResult to display dialog "CREATE NEW MEMBER 
Please enter your first name
" default answer ""
	set theFirstName to text returned of theResult
	set theClipboard to text returned of theResult
	if (theFirstName does not start with "Example:") then
		exit repeat
	end if
end repeat

repeat
	set theResult to display dialog " 
Please enter your surname
" default answer ""
	set theLastName to text returned of theResult
	set theClipboard to text returned of theResult
	if (theLastName does not start with "Example:") then
		exit repeat
	end if
end repeat

tell application "Address Book"
	set the_ID to (make new person with properties {first name:theFirstName, last name:theLastName, phone:"+07966284765"})'s id
	
	set the mobilePhone to ("+447966284765")
	
	
	
	save addressbook
end tell
open location "addressbook://" & the_ID

A quick search shows this: http://bbs.applescript.net/viewtopic.php?id=17953 as just one of many for making a new user.

Hmm?

I am not using “Mail” application or the address book in “Entourage”.

The address book is the standard Address Book in osX Applications.

I just want the phone number and home address to be inserted in the new card which I have been able to create. Do I have to somehow activate the EDIT mode of the card in Address Book in order to insert this info.?

Some people have tried to use a repeat tab comand, click and paste to enter a value but none of the examples I researched functioned at all.

Many thanks

Sorry - you didn’t read it through - it’s doing with email addresses what you want to do with phones. I’ve extracted it here:


set theName to text returned of (display dialog "Enter a full name" default answer "")
tell application "Address Book"
	-- Make new record. The name may need some work (for names with three words etc.)
	set newPerson to make new person with properties {first name:(word 1 of theName), last name:(word -1 of theName)}
	-- Add the phone number.
	tell newPerson to make new phone at end of phones with properties {label:"Home", value:"+447966284765"}
	-- Update Address Book.
	save addressbook
end tell

Excellent. That works!!

And the script looks more elegant than my garden shed style!

How would I add a further line which inserts notes into notes.

I was trying to use appendToNotes but that didn’t work.

Many thanks for your help.

Notes are a property of the person, so like this:


set {tName, tPhone} to paragraphs of text returned of (display dialog "Enter a full name, a return, and a Phone Number then 'Enter'" default answer "Name" & return & "Phone")
set tLabel to (choose from list {"Home", "Work", "Mobile", "Cell", "Other"} with prompt "Choose one") as Unicode text
set tNote to text returned of (display dialog "Do you want to add a note?" default answer "Note Here")
if tNote is "Note Here" or tNote is "" then set tNote to "No Note"
tell application "Address Book"
	-- Make new record. The name may need some work (for names with three words etc.)
	set newPerson to make new person with properties {first name:(word 1 of tName), last name:(word -1 of tName), note:tNote as Unicode text}
	-- Add the phone number.
	tell newPerson to make new phone at end of phones with properties {label:tLabel, value:tPhone}
	-- Update Address Book.
	save addressbook
end tell

Thanks Adam. That is exactly what I needed. I now intend to invest in applescipt studio, so that I can build a nice interface for my new club.

Regards Pete

FCP/VFX editor London UK