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

Storing function code

Important note: all examples follow aTbRef naming conventions.


Functions can be defined in any action code space:

Given their re-useable nature, Library notes are probably the most logical place for storage, but is not a requirement. But a strong recommendation as a first a choice.

Regardless of where stored, any user function, defined in any valid location (see above) in the current document, can be called from any action code in that document.

Therefore, for novice users, the last option—a Library note (first in list above), is the best place to start.

New users might choose to add only only function per note until comfortable with the process, noting the section below on naming library notes and note's $Name vs function name(s) in their $Text.

What goes in a Library note

A library note can contain:

In combination, the above two an allow Library notes to act as a way to store and share 'libraries' of code between different Tinderbox documents and/or users.

If storing non-function action code such as rules in a Library note, it may be useful to enclose such code in an inert function, thus:

function fDoNotUse(){..code ...} 

i.e. one with no inputs and no return and with a name unlikely to be called in code.

Naming Library notes

The titles ($Name) of Library notes are not used to call a function, and should not be the actual name of a function so should simply be indicative of purpose. Do not use the exact name of a user-defined function lest it confuse Tinderbox, i.e. $Name should not match a function's name.

Thus, if a Library note contains a single user function 'fDoMyTask()', do not call the note "fDoTask()". Better would be "Do MyTask" or "function fDoMyTask".

Be aware how this differs from stamp notes, where the note's $Name is the name of the stamp is called from code


Next: Naming functions