At the end of last month, I was working on trying to automate some of the aspects of maintaining the marmot by using some of Tinderbox's many features. I implemented the solution from Mark Anderson on the thread here.

That bit of action code looks like this:

if($Created.year == date("today").year){

var:string vName = date("today").format("MM y");

var:string vPath = create(vName);

};

That's a concise format, but what you're seeing is a conditional test, "if($Created.year==date("today").year)", which checks a built-in attribute "Created," (data type - date) which is automatically assigned to each note. The ".year" operator restricts the value to only the year, and compares it to "today," one of Tinderbox's keywords for date-type attributes, again with the dot-operator that restricts it to only the year.

If that condition is met (true), it executes the code within the curly-brackets. It declares two variables, each of type "string," one for the name of the note, and the other for the path within the hierarchy. The latter isn't essential for our purposes, but you can use vPath for some other purpose if you need it. You could also just go right to "create(vName);"

The next line creates the note, vName.

So you're seeing the type declaration and the value assigned in the same line. In the case of vName, today it'd create a note named August 2023.

On September 1st, it'll create a note named September 2023. The helpful bit of magic here is that create(vName) will check to see if the note already exists first. If it does, it doesn't create one, with no fuss.

So on the 1st of January, the Archive note will run its edict and notice that the archive container 2024 doesn't exist and create it. That note will run its edict, and discover that the container January 2024 doesn't exist and create it.

But there's one more important bit of magic that has to occur to make this a fully hands-off operation. How do you get the edict for the Year note into the edict tab of the 2024 container? That's where the idea of prototypes comes in.

Once I created the 2023 note that would automatically create new month containers, I duplicated that note (Edit=>Duplicate), and re-named it, p_Year. The "p_" is not a formal requirement, it's just a convention to offer a quick visual reminder within the name of the note that it's a prototype. You don't have to do that, or you can assign a little icon to it, or do nothing at all. But you do have to tell Tinderbox it's a prototype.

There are a number of ways you can do that. Each of them essentially does the same thing, it toggles the IsPrototype boolean attribute to "true" (puts a check in the box).

You can do that in the Prototype tab of the Properties Inspector for your file. You could also turn on the built-in prototypes from the File menu, which creates a Prototypes container at the bottom of your outline. Anything you place in that container is automatically assigned IsPrototype=True. (A lot of stuff happens in the Inspector, so here's a link to its entry at A Tinderbox Reference.)

I have that container open, so I just dragged the re-named duplicate to the Prototypes container. So now there's a prototype year container that already has the action code for creating all the months for any year in the future.

There's one thing left to do, to make the 2024 container (on January 1, 2024) automatically make the January 2024 container. Once a prototype is created, you add this bit of action code to the Action tab of the Action Inspector for the Archive container:

$Prototype="p_Year";

Once that's done, every year container the archive container creates will be based on the p_year prototype, and that action code for creating the month containers will already be embedded in it. Pretty cool.

I'll probably continue building out the test vehicle and writing about it, mostly to try and make myself more familiar with Tinderbox.

Originally posted at Nice Marmot 15:48 Tuesday, 8 August 2023