View Single Post
Counting how many tasks remain (and how many are completed) can take a few seconds (depending on the database), but could be added as an option like this:

Code:
property pCount : "Count Remaining & Completed tasks"
tell application id "com.omnigroup.OmniFocus"
	tell default document
		set lngTasks to count of flattened tasks
		set lngFolders to count of flattened folders
		set lngDropped to count of (flattened folders where effectively hidden is true)
		set strReport to ¬
			((((((("All Folders: " & lngFolders as string) & return & ¬
				"All Projects: " & (count of flattened projects) as string) & return & ¬
				"All Tasks: " & lngTasks as string) & return & return & ¬
				"Active folders: " & (lngFolders - lngDropped) as string) & return & ¬
				"Dropped folders: " & (lngDropped) as string) & return & return & ¬
				("Active projects: " & (count of (flattened projects where status is active)) as string) & return & ¬
				("On-hold projects: " & (count of (flattened projects where status is on hold)) as string) & return & ¬
				("Completed projects: " & (count of (flattened projects where status is done)) as string) & return & ¬
				("Dropped projects: " & (count of (flattened projects where status is dropped)) as string) & return & return & ¬
				"Inbox tasks: " & (count of (inbox tasks)) as string) & return)
		set varResponse to display dialog strReport buttons {pCount, "OK"} with title "Default document"
		if button returned of varResponse is pCount then
			-- display alert "Counting ..." giving up after 1
			set lngCompleted to count of (flattened tasks where completed is true)
			set lngRemaining to lngTasks - lngCompleted
			display dialog (strReport & return & ¬
				"Remaining tasks: " & lngRemaining as string) & return & ¬
				"Completed tasks: " & lngCompleted as string ¬
				buttons {"OK"} with title "Default document"
		end if
	end tell
end tell

Last edited by RobTrew; 2010-09-30 at 03:33 AM.. Reason: Added count of active and dropped folders