View Single Post
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:

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