Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Display Address Book contacts' weather forecast Apps
The following is an Address Book plug-in script which will pull the weather forecast for a chosen contact from The Weather Underground. Open a new document in Script Editor, copy the text in the second part of this hint, and paste it in to the document. Save the script file in ~/Library -> Address Book Plug-Ins, and call this file anything you want.

[robg adds: This script works as described; control-click on the Address field to see the option in the pop-up menu.]

Enter into Script Editor:

(* This script adds a menu, over peoples address, when you select the menu, 
it goes to the weather underground web site and displays the weather forcast 
for the given address *)
using terms from application "Address Book"
  on action property
    return "address"
  end action property
  
  on action title for per with addr
    set ccode to country code of addr
    if ccode is missing value then
      set ccode to default country code
    end if
    if ccode is equal to "us" then
      return (("Weather Undergroud forecast at " as Unicode text) & ¬
      name of per as Unicode text) & "'s " & label of addr
    else
      return ("Weather Underground forecast of " as Unicode text) & ¬
      city of addr
    end if
  end action title
    
  on should enable action for per with addr
    if city of addr is missing value then
      return false
    end if
    return true
  end should enable action
 
  on perform action for per with addr
    set ccode to country code of addr
    if ccode is missing value then
      set ccode to default country code
    end if
    if ccode is equal to "us" then
      set loc to ¬
      "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" & ¬
      zip of addr
    else
      set loc to ¬
      "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" & ¬
      city of addr & "," & country of addr
    end if
    tell application "Safari"
      if (count of documents) is 0 then
        make new document
      end if
      set URL of first document to loc
      activate
    end tell
    return true
  end perform action
        
end using terms from
    •    
  • Currently 2.00 / 5
  You rated: 3 / 5 (3 votes cast)
 
[3,363 views]  

Display Address Book contacts' weather forecast | 7 comments | Create New Account
Click here to return to the 'Display Address Book contacts' weather forecast' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
No joy here
Authored by: ssevenup on Feb 11, '04 06:04:27PM

I tried saving as Script, App and App bundle. I see no additions in CM for address fields. I am running OSX.3.2. It does appear to compile. I logged out and back in just in case. I didn't help.

--MM


---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
Which address fields are you trying?
Authored by: jecwobble on Feb 12, '04 10:44:44AM
This only works on address fields in Address Book, which only show up if you have entered one for an individual.

[ Reply to This | # ]
Which address fields are you trying?
Authored by: ssevenup on Feb 12, '04 11:00:12AM

Yup, I fugured out that CM clicking on the address field itself was required. I get Export vCard..., Map of, Copy mailing label and Copy URL of map with or without the addition.

--MM


---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
Which address fields are you trying?
Authored by: jiclark on Feb 12, '04 10:15:48PM

You have to quit and restart Address Book for the plugin to work. That should get you going!



[ Reply to This | # ]
Quit/restart
Authored by: ssevenup on Feb 13, '04 11:05:44AM
Quit and restart Address Book

As I said in the original comment, I logged out and back in. This obviously quits everything. It didn't help the situation.

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.

[ Reply to This | # ]

Display Address Book contacts' weather forecast
Authored by: sinuz on Feb 13, '04 12:15:37PM

Seemed like a nice feature to ave and it worked like a charm. But not for me...
Living in Sweden and that weather service does not support swedish characters like åäö. Which renders the script virtually useless for me.
Anyone got a nice fix for that? Like a short script that strips a word of those characters and replaces them with the closest match?
Linköping won't work but if I use Linkoping it works fine. Though I don't want to use that spelling in the address book.

/Linus



[ Reply to This | # ]
Display Address Book contacts' weather forecast
Authored by: quickbrownfox on Mar 07, '04 07:26:39PM

Apple has a useful find-and-replace sub-routine posted at:

http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.07.htm



[ Reply to This | # ]