The confusion of word count

I need to count the number of words I write each day, including # Name and $wordcount, and take all the sub-notes

I refer @mwra

Counting words in an outline’s note and all its child notes - Q & A - getting started with Tinderbox - Tinderbox Forum

But I failed

I only counted the number of words in my current notes, and the number of words in my sub-notes was not counted successfully

Also, I want the word count to be displayed in the $name row of the parent note. What should I do?

Thank you!

$NameWordCount = $Name.split(" ").count;
$TotalWordCount = $NameWordCount + $WordCount;
$MyNumber = $TotalWordCount + (sum(children, $TotalWordCount));

Ok. An important note to start, and without meaning to sound pedantic, but attribute names are case-sensitive. So if want the value of attribute ‘WordCount’ you can’t use $wordcount, it must be $WordCount. I get what you mean above but failure to use the correct case in code could be one reason your experiments are failing.

Anyway, I’ve just posted a fairly extensive demo that I think covers this here, in answer to a separate question by you on this same topic.

But briefly, to get the sum of the $WordCount of all children (and only children) and strore it in attribute ‘MyNumber’:

$MyNumber = sum(children,$WordCount);`

but to get a count for all descendants and not just children, you need to use:

$MyNumber = sum(descendants,$WordCount);`

The terms ‘children’ and ‘descendants’ here is using action code designators, on which you may wish to read up.

I this also covered in the demo to which I linked, and uses Display Expressions.