A quick draft of yet another script which updates an "OmniFocus" calendar in iCal with the current set of incomplete tasks in any 'iCal' context in OF.
Similar in function (though not coding) to Yang Yilei and Mike Erickson's drafts, but may be a little faster, and reports on how many tasks, if any, are involved.
Similar in function (though not coding) to Yang Yilei and Mike Erickson's drafts, but may be a little faster, and reports on how many tasks, if any, are involved.
Code:
property pTitle : "OmniFocus to iCal" property pVer : "0.1" -- Exports any tasks in context "iCal" -- to an "OmniFocus" calendar in the iCal app property pCalendar : "OmniFocus" property pContext : "iCal" property pblnAlarm : true property pAlarmWhen : -20 property pAlarmWhat : "Glass" tell application id "OFOC" tell default document set lstContext to flattened contexts where name is pContext if lstContext ≠ {} then set oContext to first item of lstContext else set oContext to make new context with properties {name:pContext} end if tell (flattened tasks where its context is oContext and completed is false) set {lstName, lstNote, lstStart, lstDue} to {name, note, start date, due date} end tell end tell end tell set lngName to length of lstName if lngName < 1 then display dialog "No uncompleted tasks found in the iCal context ..." buttons {"OK"} default button "OK" with title pTitle & " ver. " & pVer return end if tell application id "wrbt" set lstCal to calendars where title = pCalendar if lstCal ≠ {} then set oCalendar to first item of lstCal else set oCalendar to make new calendar with properties {title:pCalendar} end if tell oCalendar delete events delete todos repeat with i from 1 to length of lstName set {dteStart, dteDue} to {item i of lstStart, item i of lstDue} tell (make new event with properties {summary:item i of lstName, description:item i of lstNote}) if (dteStart is missing value and dteDue is missing value) then set allday event to true else if dteStart is not missing value then set start date to dteStart if dteDue is not missing value then set end date to dteDue end if if pblnAlarm then make new sound alarm with properties {trigger interval:pAlarmWhen, sound name:pAlarmWhat} end tell end repeat end tell end tell display dialog (lngName as string) & " task(s) exported from the iCal context to the OmniFocus calendar in iCal." buttons {"OK"} default button "OK" with title pTitle & " ver. " & pVer