Sometimes you want to create a note using action code. Tinderbox doesn’t provide action code for creating a note directly, but you can still create notes using what I call the “punch” technique. Essentially, you use an existing note to punch a hole in the
fabric of space and time Tinderbox document.
Here’s how it works:
- Pick a note that you will use as the “punch” note. I like to give it a specific name like
tools.punch, and use it for the sole purpose of making new notes.
- In your action code, generate a path name for your new note. Set the punch note’s
$Containerto this path.
- At the end of your action code, reset the punch note to a known location.
- Run your action code!
Although Tinderbox action code doesn’t have a function for creating new notes, it will create any intermediary notes necessary to set a
Here’s a simple example (make sure you have a note named
$Container("tools.punch") = "/My new note"; $Container("tools.punch") = "/Tools";
And a slightly more involved example to create a dynamically-named note based on the current time:
var timestamp(date("today").format("y-M0-D h:mm")); var newNoteLocation("/Records/" + timestamp); $Container("tools.punch") = newNoteLocation; $Container("tools.punch") = "/Tools";
For a working example, see the attached document. It provides two stamps that run action code – one that creates a note called “My New Note”, and another that creates a note based on the current time.
new-note-punch.tbx (59.4 KB)