Address Book Plug-Ins: Age

I have an Address Book plug-in that showed the age of a person when clicked on the "Birthday" label. Since installing Snow Leopard this stopped working. The script is still where it's supposed to be, and other scripts in the "Address Book Plug-Ins" folder still work. Any idea why the age script stopped working, and how I can make it work again?
The script – I don't remember where I found it – now looks like this:

{quote}
<pre>
(* This script adds a popup to birthday field that shows the persons age *)
using terms from application "Address Book"
on calculateAge(bdate)
set age to ((year of (current date)) - 1 - (year of bdate))
if (month of (current date) > (month of bdate)) then
set age to age + 1
else if (month of (current date) = (month of bdate)) then
if (day of (current date) ≥ (day of bdate)) then
set age to age + 1
end if
end if
return age
end calculateAge

on action property
return "birth date"
end action property

on action title for p with e
set userAge to calculateAge(e)
return (name of p & " is " & (userAge as string)) & " years old"
end action title

on should enable action for p with e
return true
end should enable action

on perform action for p with e
set userAge to calculateAge(e)
display dialog (name of p & " is " & (userAge as string)) ¬
& " years old"
end perform action
end using terms from
</pre>
{quote}

MacBook Pro 13" 2.26GHz (June 2009), Mac OS X (10.6.1), Time Capsule 500GB, Airport Express, iPod shuffle 512MB, iPod nano 8GB

Posted on Oct 4, 2009 2:07 PM

Reply
6 replies

Oct 5, 2009 3:10 PM in response to Martijn

AppleScript plugins will work regardless of the Mac architecture (PPC or Intel). However, there is a specific problem with the birthday property. If you look in Console when you try to use this plugin, you will see an Address Book error message along the lines of "record is still nil".

Message was edited by: bneely

Oct 5, 2009 3:30 PM in response to bneely

It says:


06-10-09 00:18:04 Address Book[7035] -[ABDatumView record]... record is still nil!
06-10-09 00:18:04 Address Book[7035] * Assertion failure in -[NSMenuItem initWithTitle:action:keyEquivalent:], /SourceCache/AppKit/AppKit-1038.11/Menus.subproj/NSMenuItem.m:270
06-10-09 00:18:04 Address Book[7035] Invalid parameter not satisfying: aString != nil


Does that help?

Oct 5, 2009 7:41 PM in response to Martijn

Martijn,

looks like a bug in the Address Book application itself, not the script. It seems as if adding custom actions to the birth date property are currently broken - the simplest implementation:

using terms from application "Address Book"
on action property
return "birth date"
end action property

on action title for person with bday
return "Test"
end action title

on should enable action for person with bday
return false
end should enable action
end using terms from

does not work (whereas it works just fine when replacing "birth date" with "phone" to display "Test" on any phone number label.

I suggest that you submit a bug report about this to Apple
http://bugreport.apple.com (developer account required)
or at least let them know about the issue
http://www.apple.com/feedback/macosx.html

Andreas User uploaded file

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Address Book Plug-Ins: Age

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.