View Single Post

AgentSka appears to be in north america, where Brian's code will compile and run first time.

Anyone using a system with different regional settings may, however, find that Applescript chokes on the date expressions, complaining that it is unable to parse their date format.

One way of writing code that can be run outside the Month/Day/Year zone is to use display dialog, and ask it to prompt users with a date in the format which their applescript installation will understand.

e.g. something like

property pTitle : "Enter a repeating birthday reminder"
property plngDaysNotice : 3

set strName to (text returned of (display dialog "Whose birthday:" default answer "" with title pTitle))
	set dteDue to date (text returned of (display dialog strName & "'s birthday falls on:" default answer short date string of (current date) with title pTitle))
on error strMsg
	display dialog strMsg buttons {"OK"} with title pTitle
end try
set dteStart to ((dteDue) - (plngDaysNotice * days))

tell dteDue
	set strMonth to its month as string
	set strDay to its day as string
end tell

tell application "OmniFocus"
	tell default document
		set _context to context "Email" of context "Mac"
		tell project "Birthdays"
			set _repetition to {unit:year, steps:1, fixed:true}
			make new task with properties {name:strName & "'s birthday on " & strMonth & space & strDay, start date:dteStart, due date:dteDue, repetition:_repetition, context:_context}
		end tell
	end tell
end tell

Last edited by RobTrew; 2011-02-08 at 05:07 PM.. Reason: Added text of birthday to action string