Consecutive numbering of notes?


I want to use Tinderbox for keeping track of an archive that operates on the “numerus currens” principle, i.e. the archival contents are organised by giving them consecutive numbers.

(How) Can I get Tinderbox to give each note a consecutive number that is one bigger than the last number entered? I should probably create a displayed attribute for this, I assume.

Hoping that I managed to make my problem clear, I’ll be very grateful for any ideas you can share!

I’ve not used the feature for years but the ‘sequential’ option for the number type—note the sequential box is ticked:

Now, I add some notes (i’m using Outline+column view so you can see the sequence):

You will see one possible limitation—all new notes added get a number. I added, aa, bb, cc, then a built-in prototype (that added 2 items—the prototype and its container) and lastly dd. At that point the Inspector looks like this—note the Default value:

So, we can see the count is kept my incrementing the default. To summarise, this means:

  • Ideally set-up a sequential number before first use, or set the initial default one higher than the number of pre-existing notes needing a sequential number.
    • In the latter case you’ll need a means to set the attribute’s value for pre-existing notes
  • You can alter the start/latest count number via the attribute’s Default value
  • The attribute values in notes are set at creation but are editable
  • Editing an existing value does not cause all higher values to be reset. IOW, this is a one-pass setting
  • You can’t exclude any new note from the count (I tested - this includes adornments, agents, etc., too).
    • IOW, you can’t reach ‘inside’ the process to make a conditional application.

Of course, how would the app know (internally) what things should get a count and what to ignore. That, and the fact that altering a note’s value doesn’t affect the existing values of other notes.

You could argue that you are essentially numbering the document entities in rising $Created order! That offers some other approaches that I’ll put in separate reply to avoid too long a note.

1 Like

Building on my last reply, how else might the be approached, to work around the issues stated?

My best guess is an agent that finds only notes of interest (i.e. not prototypes, template, adornments, agents, etc.). So, a query gives you only the notes you want. If the agent’s sort ($Sort or the Action Inspector’s ‘sort’ tab) is set to $Created, you now have all but only the notes of interest in the order desired. Now you can number.

An action to try, assuming a user Number-type attribute $SeqNum that holds the sequence number you desire to have:

// set item #1
// set remainder
   $SeqNum= ($SeqNum(previous) + 1);
// reset if a lower number removed from sequence
      $SeqNum= ($SeqNum(previous) + 1);

This works though it can take a little while for the agent to figure out the reset test (last if() in the agent action. But, it does work. The last test is in case you remove a lower order note and want the higher numbered items to re-number.

Here’s my test doc: sequence-test.tbx (134.4 KB)

Does that help?

1 Like

Thank you very much, Mark, for taking the time and effort for such a long reply! I much appreciate it and look forward to trying it out and seeing, whether it solves my problems.

1 Like

You could also use not $ID as this is a sequential number created when the note is created. IDs might not work, however, as they’ll also be generated for prototypes and other notes you create that you don’t want to use an NC for.

If all the notes will be created when added to a specific container you could also use AN OnAdd action code to get the NC number of the last child (assume the notes are sorted by NC) and then add one.

There are so many ways to do this.

As @mwra suggests, sequential IDs are great if your primary need is to assign some unique integer to each note. Some notes will get an integer but don’t really need one, but that does no harm for tasks like zettelkasten file systems, where what matters is that every note has a number, and no two notes have the same number.

But suppose you want to assign numbers only to a specific kind of note — say, to Guests. You want there to be no gaps: the first guest gets ticket 1, the next gets ticket 2, and so forth. Agents can handle this easily enough!

But another approach is to have a configuration note that keeps track of the next ticket number to be issued in $MyNumber(/config/Tickets). Then when we find a guest without a ticket, we fix that:

if ($Ticket==0) {
     $Ticket = $MyNumber(/config/Tickets);
     $MyNumber(/config/Tickets) += 1;
1 Like

I do exactly this for versioning pandoc draft exports.