Constructing $-references from loop variables

Want to iterate Displayed Attributes and set values from note B to the same in note A?

Constructing $Attribute references in loops is now updated to cover that.

To avoid confusing the Tinderbox parser, the tear-down from literal values to variable-based inputs isn’t exactly as you might assume.

1 Like

I absolutely love this. I’m going to use this when copying contact notes from one file to another. This will be a quick way to update multiple notes at once through and agent and two different containers.

$DisplayedAttributes.each(X){
	action("$"+X+"=;")
};

I think, for a tutorial like this, it might be easier to do this in two steps.

$DisplayedAttributes.each(attributeName){
     var:string command="$"+attributeName+"=;"
     action(command)
};

If things go wrong, you can store command in $MyString, or use show(command) to check it. The intermediate variable also gives you an opportunity to label what you’re doing, if the reader doesn’t see it right away.

That command-based approach is what used in the code added to Constructing $Attribute references in loops, but mention of show() as a means of checking the command is neat and I have added these to the article Constructing $Attribute references in loops with a new section at the end on testing. It has code examples using show() and logging by writing to the $Text of a log note.

1 Like