I have a container with 6 current. tasks that I have to complete in setting up the plot for a novel. Three of them have already been completed and have a “check mark” badge. I want the Display Expression on the Container to show how many tasks there are yet to complete.
This is the Display Expression I’ve been using, but it still returns 6 (the total number of tasks):
I’m not wild about doing work in $DisplayExpressions. Display Expressions are lazy; they can be invoked anytime Tinderbox wants to display something, and they get cranky if they’re asked to do a lot of work. (This isn’t a lot of work, so it’s fine in practice. Just saying…)
The way I might do this is to use a rule on the container.
I tried what you said; however the rule is still returning 6 (the total number of tasks) for the value $MyNumber. I want it to return 3 (the number of tasks withou the Badge “check mark.” So does this rule in words say, "Set the value of $MyNumber by adding together all children of this container whose Badge is not “check mark” ?
I’m trying to figure out how to do something similar, but a little different. Basically, I want to create a display expression that will just show the number of notes in a parent container (folder) but not include the other child containers & agents (again, just the number of notes). How would one write that kind of qualified display expression?
The collect_if makes a list of all our siblings that satisfy the following condition:
(!$IsAgent) & ($Childcount==0)
Agents won’s satisfy the first clause, and containers won’t satisfy the second clause. So we’ll have a list that only contains notes that are neither agents or containers.
As you’d expect, it didn’t work. Looking at the code more closely, it looks like this is set up for an agent. I should’ve been more clear: I was hoping to apply this to a container (folder) that contains agents.
Is there some kind of code for display expression that I can use that would accomplish what I’m seeking for displaying the count for notes, but not agents agents / containers and aliases?
As a general principle, it helps a lot to keep processing simple in display expressions. Display Expressions are evaluated frequently, and so it helps to keep them fast.
So, in general, if you are inclined to want a complex display expression, consider splitting the work in two. Let a rule or edict do the heavy lifting, storing their results in a string attribute such as $MyString. Then the $DisplayExpression can be very simple:
$Name+": "+$MyString
This also helps diagnose problems, because now you can separate the computation behind $MyString. If that’s causing trouble, try simplifying it until it can’t possibly be wrong. Then, step by step, add in complexity until you get where you want to be.