This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

Library

Library

From v9.1.0, functions written in action code may be defined in notes placed in the /Hints/Library container (more on storing function code).

The Library container's $OnAdd sets new child notes to use the built-in Action prototype. The container does not use this prototype itself and should not be used to store function code.

Notes here, i.e. descended from /Hints/Library, can contain one or more discrete action code function(s). The names of the notes are not the function so may simply be indicative of purpose. Note how this differs from stamp notes.

Tinderbox examines all library notes for function(s) and runs an action code in the note when the note $Text is edited (i.e. when the $Text is altered, not just when the note takes focus). This means Library notes can be a useful method for testing code. So if the contents of a Library note is:

$Color = "green"; 

… on selecting the note noting happens, the note's color is 'lightest black' as inherited via the 'Action' built-in prototype. If the note's $Text is edited, even just adding a space or line return, the note's colour turns to 'green'.

As this evaluation includes functions beware functions that alter other notes, as accidental changes may occur is a function is triggered by accidental 'evaluation of the note.

If wanting to store action code without it being evaluated (e.g. a complex rule's code) make a note elsewhere in the document using either the 'Code' or 'Action' built-in prototypes

Library notes can be nested with no implication other than for convenience of organisation and storage. Notes can be copied between documents, though it is left as an exercise for the user to ensure any referenced attributes are present in the new document. It is recommended the if planning to share library notes between files that any needed user attributes (and their type, etc.) are noted as a comment in the function.