Retain inherited attribute from parent when creating alias

Good (morning|afternoon|evening),

I have a problem with my tinderbox, and kindly ask for thoughts or hints to solve this:

I am creating notes that symbolise a scientific article or book. Inside these notes, I build little maps explaining the contents, keeping track of my thoughts, etc.

The notes inside the “Article” notes, which are based on a prototype called “Quote”, inherit the parent’s name (as custom attribute “Source”). They are used to track excerpts from articles, or summaries of passages. The inheritance works fine.

Until here, everything works as planned. Now my challenge begins.

I then create aliases of these quotes which I sort into various other notes - there may be some that directly relate to keywords, but most of them are a bunch of loose thoughts relating to lots of ideas that pop up in my head.

To do that, I create an alias because I wish to see changes adjust across maps. However, when copying this alias to another map/ container, the inherited name (now as user attribute “Source”) changes, as the following screen shot shows.

Initially, the “Source” entry showed “Share (2008): Anglocentrism”, which would then help me to find the article, if necessary.

Would there be a way to retain the initially inherited attribute when creating the alias?

  • I can ensure that parent-notes always come from the same 2 prototypes (article/book)
  • I may make aliases from other notes (e.g. ideas, to dos, etc.), but these do not require custom inheritance of (user) attributes
  • Another way of thought along this problem is: Can you populate (user) attributes only “once during creation” of the note? I guess this would also be a solution to my problem.

Thank you for reading this far and thinking about a possible answer.

Sebastian.

How is $Source set? Via the parent’s OnAdd action or a rule/edict in the child note.

It appears from your description that the parent OnAdd is setting a $Source value. When you make an alias, both original alias share the same value for $Source. When you move the alias to a new parent, the latter’s OnAdd sets a new $Source value effectively overwriting the original value.

Assuming the code setting $Source is like:

$Source=$Name(parent)

Change it to:

$Source|=$Name(parent)

The effect of the |= operator is that $Source is set only if it is not already set to a non-default (local) value.

1 Like

Thanks a lot, Mark. That’s exactly what I was looking for. Does the |= operator have a name?

Just to complete: I am setting the name in the code of the child, not via OnAdd at the parent’s level. Is this inappropriate?

Sebastian

Good. I believe the |= is called a ‘logical or’ - see more here.

Thanks, Mark.
After cleaning up, I had copied all my prototypes into a separate container, and experienced a new problem - now all Source-attributes were set to “Prototypes” (the name of the container where I keep my prototypes), and would not inherit what I actually wanted them to inherit. I am posting my solution in case others may have use.

I updated the code to:

if(!$IsPrototype) {$Source|=$Name(parent)}

This does the job now.

This scenario is why the $RuleDisabled and $EdictDisabled attributes got added (their state is also shown as a tick-box on the Rule and Edict Inspector. Is using a prototype whose action codes set attribute values on relative offsets (e.g. ‘parent’) then you want to disable the rule/edict in the prototype.

Having done that, in your preset situation, you might want to roll back to a version before you moved the prototypes as it might be the quickest way to clear up and move forward.

1 Like