Guest
2010-02-11, 10:42 PM
Quote:
Originally Posted by curt.clifton
With a complex database (lots of folders and projects), the necessary recursion can be slow.
|
You can get a flattened project list a little faster (and perhaps a bit more simply) by using
where queries.
e.g.
Code:
property pfSkipHiddenFolders : false
on run
tell application id "com.omnigroup.OmniFocus"
set oDoc to front document
set lstAllProjects to my ProjectList(oDoc)
end tell
end run
on ProjectList(oParent)
using terms from application "OmniFocus"
tell oParent
set lstProject to (sections where class is project)
-- OR e.g. (sections where class is project and flagged is true)
if pfSkipHiddenFolders then
set lstFolder to (sections where class is folder and hidden is false)
else
set lstFolder to (sections where class is folder)
end if
if length of lstFolder > 0 then
return lstProject & my FolderProjects(lstFolder)
else
return lstProject
end if
end tell
end using terms from
end ProjectList
on FolderProjects(lstFolder)
set lstProject to {}
repeat with oFolder in lstFolder
set lstProject to lstProject & ProjectList(oFolder)
end repeat
return lstProject
end FolderProjects
--
Last edited by RobTrew; 2010-02-12 at 05:06 AM..