Code in Rule vs Code as attribute value


(Tim Wallin) #1

Kindred spirits - I’ve just spent hours putting the code below in a container as its rule, to no avail. Then I pasted the same code into the OnAdd attribute for that container under Get Info dialog and it works great. Is there a bug, or do I need to learn a Tbx subtlety?

$OnAdd: $Prototype=“pDaily”; $Width=6; $Height=1.2; $DisplayExpression=’$Created.format(“y M0 D W”)’;

Well, actually I pasted the following into the OnAdd attribute under Get Info:

$Prototype=“pDaily”; $Width=6; $Height=1.2; $DisplayExpression=’$Created.format(“y M0 D W”)’;


(James Fallows) #2
  • If you put this into a container as its rule, it will be the rule for that container itself – but not for any of the child notes.

  • If you put it into a prototype as its rule, it will apply to all notes based on that prototype.

  • If you put into a container as its on-add action $Prototype="PrototypeYouWant", then the child notes will all have that prototype, and any rules, properties, etc you’ve assigned to that prototype.

So properties of containers themselves do not automatically convey to child notes. (You can think of problems that might crop up if notes always had similar properties to the parent container.) They way you enforce inheritance is through prototypes, on-add actions, or combinations of the two.

Good luck!


(Tim Wallin) #3

James - Thanks! I think it was the “rule as note-specific” piece that I was missing. I will experiment with your succinct summary.

Having flashbacks to FORTRAN programming with cards :slightly_smiling_face:


(Paul Walters) #4

If you want these attribute settings to be part of every note,

$Width=6; $Height=1.2; $DisplayExpression=’$Created.format(“y M0 D W”)’;

then make them part of your pDaily prototype, or part of a prototype that pDaily inherits. That’s what prototypes are for.


(Tim Wallin) #5

Paul - thanks very much for your comment. Now that you’ve said it, that bit about inheritance is blindingly obvious. I had’t yet internalized that rules are note-specific; I hope other newbies might benefit from this thread given the two sage responses. I’m increasingly sensing that Tbx is really quite a remarkable creation.