Applying a Stamp to a container AND all of its descendants

Is there a designator I can use to a stamp to use on a container AND all of its descendants?

For Example I would like to apply the stamp to Container 1 and apply the stamps actions on Container1 AND all descendants notes

Container1
Note1
Note2
Container2
Note3
Note4

My initial thought was to use the designator “descendants” as the stamp designator but I do not believe that would get Container1 in my example.

Is there another designator I could use instead to get the action I want or will I need to create 2 stamps?

Thanks in advance
Tom

[Edit: this works but the solution by @eastgate, 2 posts down, is much simpler]

How about:

$Color="red";
var vOthers();
vOthers = collect(descendants, $Path);
vOthers.each(aNote){
   $Color(aNote)="red";
};

The initial line acts on the selected note, the next line finds all its descendants and applies the same code. I’m using a variable so there is no List-type attribute to clean out after the process as the ‘vOthers’ is deleted as soon as the stamp completes.

Obviously the actual task isn’t as trivial as setting a colour, but that there just to indicate how both thee container and all descentants are acted upon.

Thanks Mark. I am moving into new territory for my Tinderbox skills with using the variable and the .each() operator. Your example allows me to understand its use case. My assumption is that there is no specific designator to use in this case is correct. The designators this() and descendants() apply only to a part of the problem which is why you suggest using a variable and .each.

Another approach I was thinking about using was to try a prototype and a rule as well. The limitation here would be that the rule would not be a once only action like a stamp. I will play with both. Thank you again.

Tom

1 Like

This will work, too!

$Color="red";
$Color(descendants)="red"
3 Likes

thanks MarkB

Variable??

That’s a rather cyptic question. If unsure of the syntax for .each loops see here.

FWIW, I’ve adopted a personal method—i.e. unofficial—of naming variables thus:

  • var() variables, I use a lowercase v prefix before a capital letter of the variable name. Thus vString or vItems.
  • in-loop variables as in .each() and some other operators, I use an a or an prefix before a capital letter of the variable name. Thus aNote or anItem. This reminds me the reference is to the loop’s current list item.

Having different prefixes helps both show these are user-defined variables and which are scoped to the action and which to within the loop.

1 Like

When writing Tinderbox action code you can set temporary user variables or leverage regex back references that will hold a data values that the action script will use later in the processing of the rule, edict or stamp. I’ll do a quick video on this weekend.

1 Like

Hi @mwra & @satikusala ,

Thanks for the replies on clarifying my doubts ! I was indeed confused with aNote whether it was a variable or not.

Apologies for the rather cryptic question . Micheal looking forward to your quick video !