Tinderbox v11 Icon

library

When calling a function, the designator library binds to—i.e. calls data from—the (Library) note holding the function. Thus, the designator allows a function to access the attributes of the note in which it is stored, essentially allowing it to have 'internal' attribute settings to assist with configuration of function process or to store global values. Example usage:

$MyResult = fDoReport($ID,$MakeLists(library)); 

For instance, the function above returns a report, an if() evaluation in-function might test whether to include a small listing of data. Such evaluation resolve a boolean. So if the Library note holding the code for fDoReport() has a user boolean attribute $MakeLists set accordingly, all use of the function fDoReport() will use the same boolean value for list creation. This is different from, but functionally similar to, reading a global value stored in a config note.

Beware scope

The designator has no meaning/value outside a function call do not do this:

$MyResult = $MakeLists(library); 

Similarly, if using action code stored in a Library note, but not written as a function, and calling it like so:

$MyResult = action($Text("My Library Note"));

will mean that if the library designator is used within the code stored in $Text, it will return no value.

To repeat, library has a useful purpose only if called from within a user function's code.

Using library vs. Config notes

These are two different ways to do broadly the same thing. Which of these approaches is 'best' is really a reflection of the exact task at hand and personal style.