Working my way through Tinderbox and experimenting with inheritance I have problem with code, that in my mind should yield identical result, but they don’t.
The task is to add children to a mother note. The color of children notes with even child number should be colored “red”, the odd numbered should be colored “bright green”.
I create a mother note and a number of notes that are to be moved into the mother container one by one.
This code is assigned as a rule to the mother note;
if(mod($ChildCount,2))
{$Color(lastChild)="red";}
else
{$Color(lastChild)="bright green";};
This works as expected and the color takes on red, bright green, red, bright green…
I tested another way to accomplish the same thing
if(mod($ChildCount,2))
{$Color(child[$ChildCount-1])="red";}
else
{$Color(child[$ChildCount-1])="bright green";};
This also works, except that after the child is added and assigned its proper color attribute, all of other child color-attribute also changes to the color of this last added child.