get address

Hi,

I found this script:

tell application "Address Book"
	set currentPerson to first item of (get selection)
	set theirName to name of currentPerson
end tell

on this forum and want to get not only the name but the adress aswell…how is this possible?

Another question I got this

set theMonth to month of (current date) as integer

This gives the number “2” as output is it possible to not get “2” but “02” ??

Thanks in advance

This works.

tell application "Address Book"
	set currentPerson to first item of (get selection)
	set theirName to name of currentPerson
	set theirAddresses to formatted address of addresses of currentPerson
	repeat with oneAddress in theirAddresses
		display dialog theirName & linefeed & linefeed & oneAddress
	end repeat
end tell

Note that a person can have several addresses

Either


set theMonth to text -2 thru -1 of ("0" & (month of (current date) as integer as text))

or


set a to do shell script "/bin/date +%m"

thanks!
the date works perfectly

the address thing does work but when I want to write it to a textfile with the keystroke option it puts everything onone line like “namestreetpccitycountry” and I want it
“name
street
pc, city
country” have a solution for this?

found the solution but when the field of country is empty I get the string
“missing value” is there a way to work a round this?
So when country is there keystrok the country name otherwise don’t keystroke a thing??

Address Book uses chr(10) to delimit lines, perhaps your txt file wants chr(13)

tell application "Address Book"
	set currentPerson to first item of (get selection)
	set theirName to name of currentPerson
	set theirAddresses to formatted address of addresses of currentPerson
	set theirAddressesForOutput to {}
	
	repeat with oneAddress in theirAddresses
		-- replace character id 10 with character id 13
		set AppleScript's text item delimiters to {character id 10}
		set myList to text items of oneAddress
		set AppleScript's text item delimiters to {character id 13}
		copy (myList as text) to end of theirAddressesForOutput
	end repeat
	
	repeat with oneAddress in theirAddressesForOutput
		display dialog oneAddress
	end repeat
end tell