Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!


Click here to return to the 'Export Address Book entries to HTML via AppleScript' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Export Address Book entries to HTML via AppleScript
Authored by: jonn8n on Fri, May 2 2008 at 9:22AM PDT
It's probably a good idea to wrap more sections in try blocks in case there is a problem with the data. In case of an error with the formatted postal address, I'd construct it manually (this follows the US's convention for formatting postal addresses, update to your country's format as desired):

repeat with i in addresses
	try
		set tmp_addr to formatted address of i
	on error
		set tmp_addr to {}
		set {_street, _city, _state, _zip, _country} to i's {street, city, state, zip, country}
		if _street is not in {"", missing value} then set end of tmp_addr to {_street, return}
		if _city is not in {"", missing value} then set end of tmp_addr to {_city, ", "}
		if _state is not in {"", missing value} then set end of tmp_addr to {_state, " "}
		if _zip is not in {"", missing value} then set end of tmp_addr to {_zip}
		if _country is not in {"", missing value} then set end of tmp_addr to {return, _country}
		set tmp_addr to tmp_addr as Unicode text
	end try
	my add_data_item("postal", label of i, postal_uri, tmp_addr)
end repeat
Jon

[ Reply to This | # ]