10.3: Add a burger locator to Address Book

Nov 16, '03 12:41:00AM

Contributed by: jimhoyt

Giving credit where it's due, this was originally posted on the Apple Discussions forum by b.neely. Address Book now supports plug-ins for the rollover action menus in the card. They can be written in Carbon, Cocoa, or AppleScript. The remainder of the hint has a sample AppleScript plugin. See the steps below the script for installing it on your computer.

[robg adds: This is the first of two hints today containing sample Address Book plug-ins created using AppleScript. This extensibility could be very useful...]

2005 Update: Please see the comment by magnamous below for an updated script that works in 2005 (as the company website has changed).


--burger time! 
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 missing value then 
      return "In-n-Out Burger locator (zipcode required)" 
    else 
      return "In-n-Out Burger locator for zipcode " & zip of e 
    end if 
  end action title 

  on should enable action for p with e 
    if zip of e is missing value then 
      return false 
    else 
      return true 
    end if 
  end should enable action 

  on perform action for p with e 
    set burgerURL to ¬
   "http://www.in-n-out.com/cgi-bin/zipsearch.pl?zipcode=" & zip of e 
    tell application "Safari" 
      set browser to make new document 
      tell browser 
        set URL to burgerURL 
      end tell 
    end tell 
    return true 
  end perform action 
end using terms from 
To install on your computer:
  1. Copy the script above, between the dotted lines
  2. Open /Applications -> AppleScript -> Script Editor.app
  3. Paste the script into the top of a new script window
  4. Save the script using these settings: Save As: in-n-out burger locator, Where: ~/Library -> Address Book Plug-Ins/; File Format: Script; Options: [x] Run only
After installing the plug-in and re-launching Address Book, you will see a new menu item in the rollover menu for a postal address. Note that this is intended for addresses in the United States that have a zip code. I recommend having Safari already running when you use it.

Comments (16)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20031106193307666