I think.

Went back to the Automator application, which sole function was to populate the $Text attribute with a summary of the next three days' Calendar events.

I'm getting better, or at least more familiar, with Automator. I figured out how to set the value of a text variable from an input.

I learned earlier how to pass an Automator variable to an AppleScript in an Automator workflow.

So I did the whole thing in Automator, which means I don't need the function at all.

The prototype p_Day contains the edict

runCommand("open -a MidwatchEntry");

The AppleScript in the Automator application MidwatchEntry now creates the entire Midwatch entry. It doesn't just try to paste the contents of the clipboard into the $Text attribute of the Midwatch entry created by the function fMakeMidwatch, which is now defunct. It's the same AppleScript that creates entries for Mail items, except it doesn't query for the $Name and $Text, instead creating them from variables defined in the workflow.

But...

As I was writing this, Tinderbox blinked. I have four documents open, and that kind of suggested one of them had just done something, and I suspected I knew which one.

So, putting an Edict in p_Day to run MidwatchEntry wasn't a good idea. Scratch the above.

It was fine running strictly as Action code, Tinderbox wouldn't create another Midwatch note on its own. But AppleScript will.

(Hilarity ensued earlier as multiple copies of the Midwatch entry kept getting generated. Every time I'd delete one or two, another one would appear. Insert Sorcerer's Apprentice reference here. Every "touch" of deleting one stimulated the creation of another one. Oy.)

I was going to try and figure out a conditional, but then I had another thought. (It's morning and though I didn't sleep well, I think better.)

The OnAdd action will run precisely once. So I added the runCommand action to the onAdd attribute of p_Month. p_Month creates each new day, (And I'm about to learn if I'm an April fool.) and as it adds the new day it will run MidwatchEntry, which will find that new day and create its namesake in it with the calendar event summary, and then sit quietly until the next time it's called, roughly 24 hours later, not every few hours or every time some change occurs to the document.

At least, I hope so.

I've been wrong before.

So wrong, so many times before.

✍️ Reply by email

Originally posted at Nice Marmot 07:02 Thursday, 28 March 2024