Tinderbox Forum

How to define Function properly?

Please help to understand how to use the function option. From Help topic it was not obvious where fuction is defined: in Note text or elsewhere? And where to place the note that defines functions.

Oh, a wonderful question.

A function is a note that lets you stream one or more sets of action code. Yes, that same code can be put in Stamps, Action Links, OnAds, OnRemoves, Rules, Edicts, action(). You can learn more about them here: Functions.

  1. Enable Hints, to the File menu and select "Build-in Hints. This will add a Hints container at the end of your file.
  2. Open the Hinds Container and go to the Library
  3. Write your function (see below and the attached for an example
  4. Put the name of the action, e.g. fTaskStatus();, as value in any feature that supports action code (see above).

That’s it. You’re running a function.
A cool thing about functions is that they can ingest and output inputs, inputs from notes and outputs to to other functions and actions (more on this later, let’s get the basic working first).

Here is a function assigned to tasks. This function changes the color of the note deepening its status.

I’ve placed the function in a $Rule:

Also, as shown here, you can trigger a function from anywhere else, e.g. in a Stamp, rather than in a rule. See the “Another Note”.

Here is a sample file:
TBX L - Using Functions Task Status Example.tbx (142.2 KB)

In a task simply change the status and the checked box.

1 Like

Michael, thank you for this post! It couldn’t been explained better. So clear. And thank you for the file. I think that this information ought to be added to Tinderbox help file, so other people would not ask same questions. Looking forward to your explanations how to use functions efficiently.

1 Like

Thanks Michael,

By way of a slight tweak, I find it useful to add an else{…} to switch values back to previous etc… in the case of inadvertent boolean selection

   $Status="Not Started"