Important note: all examples follow aTbRef naming conventions.
Functions can be defined in any action code space:
- Library notes.
- Action attributes: Rule, Edict, AgentAction, OnAdd, OnRemove, etc. (see all).
- Stamps (note or Inspector).
- A note with the 'Action' prototype set (edge case, not generally recommended unless the above don't suffice)
Given their re-useable nature, Library notes are probably the most logical place for storage, but is not a requirement. Regardless of where stored, every function in the current document can be called from any action.
So, for novice users, the last option—a Library note, is the best place to start. Also, new users might choose to add only only function per note until comfortable with the process.
A library note can contain:
- one, or more, discrete functions.
- other arbitrary action code expressions, e.g. rules, agent actions.
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 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.
Next: Naming functions