Prototype that change box color

Hi all, just a beginner question…

I have a prototype with an attribute, say “car color”, the Type is set to be a list. I wish to know how to get that new notes with this prototype change their box color depending on the attribute’s content. E.g.: if “car color” contain the word “blue” then the box will be colored with a blue color, if “orange” then then the box will be colored with a orange color.

Thanks for you help!

Is there a reason that you need $CarColor to be a list? Parsing lists in Rule is certainly feasible, but if all you want is to determine what the interior color of the note should be, why not make $CarColor a string or color attribute. Or, merely set $Color as a key attribute and set it directly.

Anyway, if $CarColor is defined as a color attribute, this sort of thing would work:

I think you’re trying to set the list of possible values the wrong way. A car will only be one colour (scheme) at a time so what you want is a String, or Color (see last post above) Type attribute which holds a single value. For this attribute, set its ‘suggested’ values and you can easily set a colour for a new car via key attributes.

I agree with the last answer on using a Color-type attribute. Don’t forget you can (per TBX doc) define your own named colours. So if colours you need are missing you can add them and if existing named colours are the wrong shade you can either redefine their colour or add more new ones of your own.

2 Likes

Thanks to both of you for your answers.
I think it has caused confusion by making an example maybe not very correct I’m very sorry for this.

Maybe you can better understand my need if I put the problem I really have:

I have notes about art in which one of the fields is “typology” and I created it as a list, only now I understand that a list allows the insertion of multiple values and I do not need it. So I create this field as “string”.

These notes concern paintings or photographs, so I want a “typology” field in which to insert “painting” or “photograph”. What I would like is that - depending on whether I insert “painting” or “photograph” the note is of a color, say blue for the paintings and red for the photographs.

Thank you again, for your kindness. I’m trying to understand this software (with some difficulty) because I can see many potentialities. The fact is that I come from many years of using traditional relational databases like FileMaker and this condition my way of thinking differently from Tinderbox.

No problem. OK, we’ve a String attribute we’ll call $Typology. At this point, we’ll assume there are only 3 possible values: “painting”, “photograph” or no value. We’ll assume, for this example that paintings need to have the $Color ‘blue’ and photographs the colour ‘blue’.

In your prototype, set this rule:

if($Typology==""){
   if($Typology=="painting"){
      $Color="blue';
   } else {
      $Color="red";
   };
} else{
   $Color=;
};

First we test $Typology has a value and if not we reset $Color to its default. For notes with a value, if $Typology is a painting we set the note $Color to blue, and if not to red. N.B. the $Typology and $Color values are case-sensitive.

If you need more choices, then you might want to move on to a look-up table but that’s probably a bit advanced at this stage.

I hope that helps and do please ask if stuck.

Definitely forget “database” entirely. You’re in a different universe.

If I were doing this, I would have an agent like this one for the photographs

and a similar agent for the paintings. Notice that I set the agent priority to “lowest” since you don’t need for this agent to be operating frequently.

@mwra’s use of a Rule is also a good approach. I would prefer the agent over the rule, personally, since for any given note the rule needs to operate only once – paintings probably do not become photographs and vice versa. For that same reason, instead of using agents with “lowest” priority you could use a Stamp which is applied only once to a given set of notes (with logic similar to @mwra’s coding for his rule), or you could use an Edict, which is like a rule but operates with very low frequency.

1 Like

Got it! Now I begin to understand. :wink: Thanks so much!