November 29, 2010
MarkBernstein.org
 
Follow me on Twitter

Tinderbox: getting information from other notes

Let’s take a moment to look at one of the tricky corners of Tinderbox. How can one note find out about its neighbors, or about other notes in your document?

Usually, a Tinderbox note is chiefly concerned with what it says and with its own properties. But sometimes, a note needs information from other notes – either for exporting that information, or to use in an action. Collections of notes, each with their own simple and small actions, can work together to do make your notes organize themselves in surprisingly effective ways.

When might a note be interested in other notes? Let’s imagine some examples:

Let’s look at the mechanics. For example,

$Text

is the text of this note. We can export it:

^value($Text)

or we can test it

if( $Text.empty ) { ... do something ... }

or we can set it.

$Text="....something -- perhaps results from another program...";

But suppose we’re interested in the text of some other note. We might, for example, want the text of our container:

$Text(parent)

Or, we might want the text of a particular note whose location we know

$Text(/configuration/weblog/credentials)

If we know that we have a child note called "references", then

$Text(references)

will look first for that child note. If there isn’t a child named “references”, we’ll look for the first note in the document that is named “references”.

We can combine these designators, too.

$Text(parent(parent))

gives us the text of the parent of our parent.

$Text(nextSibling(parent))

gives us the younger sibling of our parent – our “uncle”.

$Text(references(parent))

gives us the note named “references” that is a child of our parent.