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
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