Aside, note that operators are case-sensitive in name and start with a lowercase letter, e.g. while()
and .format()
. No criticism meant there but such small things create silent failures. Also Tinderbox’s parser ignores white space between the operator and its parentheses (for input arguments in any), I think it enlightened self interest to not make the parser have to think and avoid such usage. IOW:
if(condition){...
// not
if (condition) {
though both work. But, to the task at hand…
So your Edict runs and needs to says "is today’s year the same as the $Created-derived year for the current note? If it is, make a new child note using the format month-space-year’ as in “July 2023”.
For other readers, we know from create() documentation that passing a unique note name (not a path) to create() automatically makes the note as a new last child of the current note/container if that note doesn’t already exist).
So, and removing the need for two attribute-stored values in you code above:
if($Created.year == date("today").year){
var:string vName = date("today").format("MM y");
var:string vPath = create(vName);
};
The var:string vPath =
bit isn’t strictly needed but if used, variable vPath
now holds the $Path of the note you just created in case you need to further customise the new note.
So, surfacing an implicit assumption, the note (container?) on which the Edict is run has been created during the current year. What might go wrong with that? It’s now later this year, in December and you need to get back to the party, so thinking ahead you quickly create the ‘2024’ container for your forthcoming New Year’s Day post. Oh dear, as the $Created for the container will still be 2023. Safer might be to have a BlogYear
attribute (string or number, here I don’t think it matters) in which you explicitly put the to-be-current (4-digit) year. Now the Edict code becomes:
if($BlogYear.year == date("today").year){
var:string vName = date("today").format("MM y");
var:string vPath = create(vName);
};
or without the path bit:
if($BlogYear.year == date("today").year){
var:string vName = date("today".format("MM y"));
create(vName);
};
Now the year checked is the one you actually set not the one you possibly didn’t mean to set.
Does that help?