Jon (disappearinjon) wrote,
  • Mood: accomplished

For users of Apple's OS X Address Book

... I just modified this In-n-Out Burger Locator Address Book plug-in, and turned it into a Zip Code Locator, for when you don't have an address' zip code.

I'm new to AppleScript, so there are probably a number of better ways to do things. In particular, if you already have a 5-digit zip code, you can't get the Zip+4. It would also be nice to be able to parse the USPS Web page and actually put the zip code into the address book, but I don't even want to think about what that would take.

In any case, if you have any further advice/improvements/questions/etc., please feel free to comment here or send me an e-mail.

To install the plug-in, open script editor, copy the text of the script in, and save it with a sensible name (like 'Zip Code Locator,' perhaps) in the "Library -> Address Book Plug-Ins" folder under your home directory. Save it with a File Format of "Script." Quit your address book, and re-start it.




-- zip code locator
using terms from application "Address Book"
	on action property
		return "address"
	end action property
	
	on action title for p with e
		if zip of e is not missing value then
			return "Zip Code Present"
		else
			return "ZIP + 4 Lookup "
		end if
	end action title
	
	on should enable action for p with e
		if zip of e is missing value then
			return true
		else
			return false
		end if
	end should enable action
	
	on perform action for p with e
		set LookupURL to ¬
			"http://zip4.usps.com/zip4/zip4_responseA.jsp?Selection=1&address1=" & street of e & "&city=" & city of e & "&state=" & state of e
		tell application "Dock" to open location LookupURL
		return true
	end perform action
end using terms from

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

  • 8 comments