Determining a rule to define a color

Hi! I know this question has been asked before, but I can’t find the corresponding thread. When I enter a note, I first need to determine its prototype. This allows me, among other things, to determine its color. I’d like to bypass this step. To do this, I guess I have to develop a rule: whenever the attribute is a given prototype, then the color of the note must be the same as that of the specified prototype. How would I write this rule? It doesn’t work like this:

if($Type="Journal de recherche") ($Prototype="Journal de recherche";)

Thanks for your answers.

using the equality operator "$Type=="should help

Tom

Thank you Tom. I found the thread where I asked a similar question about colors, but I’m not getting the result I’m looking for with this code:

$Color=;
if($Type=="Journal de recherche") {$Prototype="Journal de recherche"};

Typically, a note inherits its color from the prototype; no rule is needed.

If the note already has a color, and you want instead to inherit the Prototype’s color, an one-time action (OnAdd or Stamp) will suffice: $Color=;.

1 Like

Why do I need to complicate things when they can be simple? Thank you!

But, it is, albeit unintentionally, complicated for most who aren’t from a tech background. Mentally, we humans tend to see when = means assignment (‘set this to that’) or equality (‘is this exactly the same as that’). It is harder for a computer program to do that with our blink-of-an-eye finesse. In fact, Tinderbox does try to figure the same if you use = for both, as originally the app’s automation was far simpler and offered less scope for error. From c. v5 (v4.x?), == became the ‘correct’ operator for equality (with Tinderbox still guessing if meeting = inside a query).

Where to look if lost again on the = vs == meaning?

My suggestion is the easiest pace to find and see the different operators is in aTbRef’s full operator listing. Happily for just such quick look-up reasons, the page is also a quick link at top and bottom of every aTbRref page—see below:

In the list, both the operators list together (digital sorting is not always so kind!):

In this sort of case, that list may be enough to answer the “which operator?” question or of course you can click through to a full description.

Nite: I’m just back-filling some links maily for others who might come here later with the same question.

†. Disclaimer: yes, I wrote aTbRef. So any errors there are down to me!

3 Likes

Thank you Mark for this explanation. I was wondering: are these values ​​related to the C language? I mean: if I wanted to get familiar with these operators, is it really the c language that I should learn?

Action code is not formally based on any one coding language, but draws on notions of a few. Action code started out as an internal macro system and then grew over the next 24 years, ad hoc as the app and its users needed: compare v1 and v10 use of actions. So learning language X in order the better to learn action code may not be fruitful. However, some general familiarity with programming notions likely does help.

Mark B may likely clarify that a bit. :slight_smile:

This topic comes up occasionally but consistently. I wonder if a short article in aTbRef on this topic that we can simply link to might be useful in the future for all.

1 Like

The “==” operator did originate in C (for practical purposes) but there’s really not much to know here. Dennis Ritchie, the programmer behind C, was uncomfortable with the two meanings of “=” in ALGOL-60, and introduced == to disambiguate. = means “perform an assignment”, == means “test for equality”.

In Tinderbox, though, it doesn’t matter much. == is a safer way to compare, but in most contexts = will have the same effect.

1 Like