The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Script: Export (from an 'iCal' context) to iCal (http://forums.omnigroup.com/showthread.php?t=23927)

RobTrew 2012-04-10 07:21 AM

Script: Export (from an 'iCal' context) to iCal
 
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.

[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

[/CODE]


All times are GMT -8. The time now is 06:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.