on searchEvents() set currentWinner to {null, 86400} tell application "iCal" set theCalendarList to (every calendar) repeat with theCalendar in theCalendarList set eventList to get ((every event of theCalendar) whose (filepath of open file alarm of it) is not missing value) repeat with anEvent in eventList set alarmPath to ((filepath of open file alarm of anEvent) as string) if alarmPath contains (POSIX path of (path to me) as string) then set diffdate to ((current date) - (start date of anEvent)) if diffdate is less than 0 then set diffdate to -1 * diffdate end if if diffdate < item 2 of currentWinner then set currentWinner to {anEvent, diffdate} end if end repeat end repeat if item 1 of currentWinner is not null then return description of item 1 of currentWinner as string return "" end tell end searchEvents set theBlastString to searchEvents() if theBlastString is not "" then tell application "MoodBlast" to blast theBlastString