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)
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