Tinderbox Forum

Qualifying a Display Expression

(Michael Brown) #1

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

$Name+" : "+sum_if(children,$Badge!==“check mark”,1)

What am I doing wrong? Or is there a better way to do this?


(eastgate) #2

$Badge !== “check mark”

The operator should be !=. We use == for equality because a single = means assignment. But != is unambiguous.

(eastgate) #3

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.

$MyNumber = sum_if(children,$Badge!==“check mark”,1)

Then the display expression can be simply

$Name+": "+$MyNumber

(Michael Brown) #4


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” ?

(Michael Brown) #5

I tried with both: $MyNumber = sum_if(children,$Badge!=“check mark”,1)

and with: $MyNumber = sum_if(children,$Badge!==“check mark”,1) [!==]

Both return 6, instead of 3.

(Michael Brown) #6

I fixed it by putting the negation in front:

$MyNumber=sum_if(children,!$Badge==“check mark”,1);

Is that kosher?

It did work, and I tested by adding and removing checkmarks and got correct number.

(eastgate) #7

Yes, that’s fine. As a matter of style, I prefer

!($Badge==“check mark”)

Also, beware of curly quotes – you wasn’t straight quotes in your actions!