Tinderbox Forum

Multiple duplicate displayed attributes getting created on note ! a bug?

Hello,
An odd problem. multiple duplicate displayed attributes are getting created in notes.
I have action code which displays and sets an attribute (in agents, and in Stamps in various places), in the following format.
$DisplayedAttributes=$DisplayedAttributes + “Tags”;

($Tags is just and example, it happens with any attribute)
I thought this was the way to add a displayed attribute without hiding the existing ones, but it creates duplicates.

this seems to be since v9.

I tried the new += way of adding, and it does the same thing…
Any help appreciated.
Best
Thomas

$DisplayedAttributes in v9.0.0+ is List type. Prior to v9 it was a Set. But as Sets now actively re-sort themselves, and the user needs to be able to control the Displayed Attributes list order, the attribute needs to be a List.

A notable difference between Lists and Sets is that Sets de-dupe themselves and Lists don’t. So a List can contain the same value more than once. This is expected behaviour

$DisplayedAttributes’s default value is nothing, i.e. "". Now let’s use the stamp (or a rule, edict or agent action) to apply this code:

$DisplayedAttributes=$DisplayedAttributes + "Tags";

The result:

Now lets ryn the action 3 more times and see the result:

$DisplayedAttributes is a List and we’ve added 3 more thinfs to it. So as we’ve instructed it the attribute now displays the $Tags attribute 4 times, as the $ Displayed Attributes attribute value is “Tags;Tags;Tags;Tags”:

So. Don’t use the code in an action that repeats automatically, e.g. a rule, edict or agent action.

HTH

An easy way to avoid duplicates:

if (!$DisplayedAttributes.contains("Tags")) {$DisplayedAttributes += "Tags";}
2 Likes

Many thanks for the super clear replies. Thats really helpful.
Best
Thomas