Tinderbox Forum

Tinderbox Training Video 62- Dynamically create notes from attributes with functions

TBX L - Dynamically create notes from attributes with functions

Level Advanced
Published Date 12/13/21
Revision 4
Revision notes 1/2/22 R4: Update method for short title creation; R3 uses @webline’s model for pulling in the value from the note’s $Rule to process the value passed to the function (see below). We still need to work on this for the unliking process.
Acknowledgements Much inspiration for this from Mark Anderson @mwra, @TomD, @Christoph, @Sherrell, @webline
Type How To
Tags 5Cs of Knowledge Management and Exchange, 5CKMEl, Action Code, Functions, Hints, Library, Linking, Templates, Tinderbox, aTbRef
Video Length 29:24
Video URL https://youtu.be/H01w4lNXMuo
Example File
TBX L - Dynamically create notes from attributes with functions R4.tbx (288.8 KB)
TBX Version 9.1
Instructor Michael Becker

In this lesson, I explain how to use action code and the new library function in Tinderbox 9.1 to dynamically create notes, and link and unlink notes, based on the value you put into attributes. This process is useful when you’re writing and want to associate throughout or relationships, e.g. a term, location, contact, event, related to the note you’re working on and then later expand on that thought or relationship. For example, this process is perfect for capturing terms (aka keywords, tags) while you are writing. You can assign a term to your note, and then later define that term. This definition can be linked within your text, included in an index, and more.

There is a lot going on in this lesson. You’ll need to spend time with the sample file to deconstruct all the elements, especially if Tinderbox fundamentals (aka prototypes, action code, templates) are not familiar to you. I explain:

  • Action Code
  • Library functions
  • RegEx
  • Linking
  • Templates and style sheets
  • Use of a config file
  • 4 Cs of knowledge management: collection, curation, creation, contribution (I don’t touch on the 5th C collaboration)
  • Simple hotkeys that I often use

TBX L - Dynamically create notes from attributes with functions

Complete video list

You’ll find a Tinderbox reference file for this video on the Tinderbox Forum: Mastering Tinderbox: Training Videos (Complete List)

You’re Invited To Be My Patron:

A lot goes into creating these training videos. If you’re getting value from these videos and are open to supporting my efforts, I respectfully ask that you consider becoming one of my patrons by making a monthly contribution. :pray: Michael Becker is creating training materials and thought-leadership | Patreon :pray:

An invitation to connect

Life is change. To meet the moment, I’m constantly on the lookout to understand what I should keep doing, stop doing, or do differently. I’m on a mission to understand the 5Cs of knowledge management (collection, curation, creation, and contribution) and for insights to balance The Identity Nexus—the intersection where equitable personal data & identity exchange happens. I’m looking to understand the personal data & identity marketplace—to track leading organizations, people, and resources (strategies, use cases, business models, standards, people’s sentiments, etc.). I welcome the opportunity for industry collaboration. Let’s connect on,

LinkedIn: https://www.linkedin.com/in/selfsovereignidentityprivacyshaman/

Twitter: https://twitter.com/privacyshaman


Hey, just saw that the audio on my video was broken. I’ve rerecorded it and just published a new version. There is a new TBX file to, see above.

Great video again - thanks a lot!

Just a small remark - I would prefer if a function doesn’t need to know anything about the note that calls this function - so I would pass the attribute to be manipulated to the function instead of hardcoding the attribute into the function itself.

function fCreateLinkTerm(term){...}

and fCreateLinkTerm($Term) to call the function.

If you pass the attributes in this way:


You could use a single function instead of four:

function fCreateLinkTerm(term){
//Create terms that do note exist. Link them to the note with link type "Term"

var vTermDict = dictionary(term);
//Set variables to be used in the function
var:string vContainer = vTermDict["cont"];
var:string vPrefix = vTermDict["pref"];
vPrefix = vPrefix.replace("#"," ");
var:string vLinkType = vTermDict["lity"];
var:string vAttri = "$" + vTermDict["atty"];

//For each value in the relevant attribute create a new note.

  var vNote=vPrefix+x;

//Link the newly created note to the original note.
  var vNote=vPrefix+x;
  var vPath=vContainer+vNote;

No critic on your code - just a different approach.
Thanks a lot for your great work!

Yup, I agree. This works well for the create function. For those interested here is an updated sample file and what the $Rule would look like:

Note: I don’t see how this consolidated approach would work for unlinking. There are two issues, that can be figured out and one that cannot. First, there would need to be a conditional to on the unlinking note name for those notes that don’t have a prefix, or you not match on name but rather $ID. Two, and this is the one I don’t know how to figure out, you can’t pass a variable to the links action code:

You can replace “Term” with a variable. I don’t see any work around on this. You’ll still need a unique unlink function for each attribute until such time we can pass variables to the links action code.

TBX L - Dynamically create notes from attributes with functions R3.tbx (288.5 KB)

eval() should help with the unlink function?!

The eval be fine, yes. And the condition of prefix or not prefix can be addressed with a condition. But, right now, in the links() action the linktype is won’t accept a variable. I don’t see away around this.

Nice job Michael. Excellent practical example of a strategy to begin building terms from your notes and linking them together. I like the way you took it one step further by creating a template summarizing the linkages.

Thanks for sharing the file.

1 Like

Let’s us not forget that this all started with that Thursday night call about 6 weeks ago - “Hey Michael, any idea how to do this???” Your insights inspired much of this. As did the conversations I’ve had with a few others.

BTW, I’ve tried different ways to use eval() to insert the term in the links action code, but have failed. If anyone can give it a go that would be great.

try this one:

$MyString = "agree";
$MyString = "links.inbound." + $MyString + ".$Name";
var:list vLinkedNote = eval($MyString);
$Text = vLinkedNote;

works for me!

testEvalLinks.tbx (104.8 KB)

1 Like

Yes, this works great!!! :pray: @eastgate, we have a solution for the previous request, so that request can drop way down the priority list.

Hi Michael

What does the eval operator change the process for the template for dynamically creating notes from attributes with functions. I am still not getting what eval() solves. Can you also post an update?

thanks Tom

"links.inbound." + $MyString + ".$Name";

should and will return a simple string. But now TBX is not able anymore to detect the contained action code. It’s a string like “hello world” no magic anymore. With eval you tell TBX to take this string and interpret it as if it were action code - with “hello world” nothing would happen, but with “links.inbound.agree.$Name” you have valid action code transformed back into the magic syntax that allows TBX to interpret it.

1 Like

Another way to say this is the eval() tells tinderbox to “evaluate” the provided string, i.e. evaluate and action code, export code or attribute references made in the string.

In the above example this $MyString = "links.inbound." + $MyString + ".$Name"; creates an action code string that includes the $Name attribute by name, i.e. unevaluted. This vLinkedNote = eval($MyString); then tells tinderbox to evlaute the action code, i.e., run it and return the results, in this case it is retruring links.inbound."agree".$Name;, it is replacing $MyString with “agree”.

Pretty slick… you might want to update the template when you have time in the unlink example. When you have a moment in your busy schedule.

Here is the line I changed in the Unlink function thanks to you and Detlef!

var:list vUnlinkNote=eval(vLinkedNote)-$Code;

Cheers, Tom

1 Like

Ya, I’ll take a look at that. Note, you’ll need to do more than this: var:list vUnlinkNote=eval(vLinkedNote)-$Code; You’ll need to add in the extra variables and update your $Rule or $Edict as necessary. Can’t really say what needs to be done without seeing your specific use case.

Hi Tom,
and you should consider “eval()” as a kind of “special” function not ment to be needed in “normal” tasks - it’s no voodoo, but nothing needed to execute Action Code most of the time. If you find a solution without eval() → use this approach.

1 Like