The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Does context totaler script exits? Thread Tools Search this Thread Display Modes
In vain I have searched this wonderful forum for any simple script that would create a table of context totals.

Ideally it would be similar to script & table found in this thread which I use extensively:

http://forums.omnigroup.com/showthre...ght=Statistics

What I am envisioning is something along the following lines for each individual context:
@Call = 15
@Mac = 49
@Waiting for = 209
etc.

Question: Does this script exist already or is it easily created?

Thank you in advance.
 
The basics might look something like this:

Code:
property pTitle : "Remaining task count for each context"
property pVer : "0.01"
property pPrefix : "@"
property pDelim : tab

property pblnToClipboard : true

set str to ""
tell application id "OFOC"
	tell default document
		set {lstName, lstCount} to {name, remaining task count} of flattened contexts
		repeat with i from 1 to length of lstName
			set str to (str & pPrefix & item i of lstName & pDelim & (item i of lstCount) as string) & linefeed
		end repeat
		if pblnToClipboard then set the clipboard to str
	end tell
end tell

display dialog str buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
 
Curt Clifton made a widget that does something like this, if memory serves.

It's called wheretofocus. I think you can get it here.


http://www.curtclifton.net/projects/
 
Quote:
Originally Posted by RobTrew View Post
The basics might look something like this:
Though it might make more sense to reproduce the nesting of the context tree, to show where a parent count includes summing of descendant counts:

Code:
property pTitle : "Remaining task count for each context"
property pVer : "0.02"
property pPrefix : "@"
property pDelim : "  "
property pIndent : tab

property pblnToClipboard : true

on run
	tell application id "OFOC" to set str to my ListContexts(contexts of default document, "")
	
	display dialog str buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
end run

on ListContexts(lstContexts, strIndent)
	set str to ""
	tell application id "OFOC"
		repeat with oContext in lstContexts
			tell oContext
				set str to str & strIndent & pPrefix & its name & pDelim & (remaining task count as string) & linefeed
				set lstChiln to contexts
				if lstChiln ≠ {} then set str to str & my ListContexts(lstChiln, strIndent & pIndent)
			end tell
		end repeat
		return str
	end tell
end ListContexts
 
Quote:
Originally Posted by RobTrew View Post
to show where a parent count includes summing of descendant counts
You could also separate the count of tasks specifically assigned to a parent level from the sum of tasks assigned to descendant levels.

(And display a global total).

Code:
property pTitle : "Remaining task counts for contexts"
property pVer : "0.03"
property pPrefix : "@"
property pDelim : "  "
property pIndent : tab

property pblnToClipboard : true
property pblnSubTreeCounts : true

on run
	tell application id "OFOC" to set {str, lngTotal} to my ListContexts(contexts of default document, "")
	set str to str & linefeed & "TOTAL: " & lngTotal as string
	
	if pblnToClipboard then set the clipboard to str
	display dialog str buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
end run

on ListContexts(lstContexts, strIndent)
	set {str, lngCount, lngTotal} to {"", 0, 0}
	tell application id "OFOC"
		repeat with oContext in lstContexts
			tell oContext
				set lngCount to remaining task count
				set lngTotal to lngTotal + lngCount
				set {strSub, lngSub} to my ListContexts(contexts, strIndent & pIndent)
				set lngThisLevel to lngCount - lngSub
				if pblnSubTreeCounts then
					if lngSub > 0 then
						set strSubTotal to "  (+" & (lngSub as string) & " in sub contexts)"
					else
						set strSubTotal to ""
					end if
				else
					set strSubTotal to ""
				end if
				set str to (str & strIndent & pPrefix & its name & pDelim & lngThisLevel as string) & strSubTotal & linefeed & strSub
			end tell
		end repeat
		return {str, lngTotal}
	end tell
end ListContexts
 
RobTrew,

Spot on script. Thank you very much. I do appreciate your quick & effective response.

Regards,
Todd
 
Good - I'm glad that meets the need.

Tidied up a little here for legibility, in case you need to adjust it.

(Forum settings no longer permit updating earlier posts)

Code:
property pTitle : "Remaining task counts for contexts"
property pVer : "0.04"
property pPrefix : "@"
property pDelim : "  "
property pIndent : tab

property pblnToClipboard : true
property pblnSubTreeCounts : true

on run
	tell application id "OFOC" to set {str, lngTotal} to my ListContexts(contexts of default document, "")
	set str to str & linefeed & "TOTAL: " & lngTotal as string
	
	if pblnToClipboard then set the clipboard to str
	display dialog str buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
end run

on ListContexts(lstContexts, strIndent)
	set {str, lngCount, lngTotal} to {"", 0, 0}
	tell application id "OFOC"
		repeat with oContext in lstContexts
			tell oContext
				-- COUNT AND REPORT FOR SUB-TREE
				set {strSub, lngSub} to my ListContexts(contexts, strIndent & pIndent)
				
				-- COUNT ASSIGNMENTS TO THIS LEVEL (SUBTRACTING SUBTREE ASSIGNMENTS)
				set lngCount to remaining task count
				set lngThisLevel to lngCount - lngSub
				
				-- REPORT ON THIS LEVEL, APPENDING SUB-TREE REPORT
				set strSubTotal to ""
				if (pblnSubTreeCounts and (lngSub > 0)) then set strSubTotal to "  (+" & (lngSub as string) & " in sub contexts)"
				set str to (str & strIndent & pPrefix & its name & pDelim & lngThisLevel as string) & strSubTotal & linefeed & strSub
			end tell
			
			-- AND KEEP A RUNNING TALLY FOR REPORTING TO THE LEVEL ABOVE
			set lngTotal to lngTotal + lngCount
		end repeat
		return {str, lngTotal}
	end tell
end ListContexts
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 11:01 AM.


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