Got a nice note from Mark Anderson about the preceding post. Some insights on functions that I need to explore.

He wondered how aTbRef might be improved to make it less "intimidating," noting that it is intended as a reference and not a tutorial, though there are many examples.

I don't think there's any need to change anything. As a reference, it's invaluable. What makes it intimidating is that it demands close reading, and that is sometimes challenging from a computer screen. Nevertheless, it is possible, as I've managed to figure out how to create the Midwatch entry using a function, and not local variables within each Day container.

This requires sending an argument to the function, the bit of data from the calling note that the function needs to do its thing. In this case, I have to pass the $Path of the current Day container, so that the Create action has an entire path to make the new note unique within the file.

I write this now, after having successfully tested the code. It looks like this:

function fMakeMidwatch(iThisPath)

{

var:string vMidwatch;

vMidwatch=iThisPath+"/Midwatch";

create(vMidwatch);

};

The p_Day prototype includes an Edict that simply says:

fMakeMidwatch($Path);

No sandbox variable, $MyString, to stick around like “data dust,” as Michael Becker calls it. So a new day is created, the Edict runs, a new Midwatch entry is created, and an Edict in it launches a little app that creates the $Text content of the entry.

After just spending the better part of an hour trying to figure out why it wouldn’t work (It’s evening. My brain is tired.), when it was all because it was missing a closing semi-colon, I think the list of tips should be as follows:

1.Always check for semi-colons

2. Always include parentheses, even if no arguments

3. Always define your variables

4. Don't forget to check for the closing semi-colon (outside the curly-brace).

I've got one last refinement to make to the Midwatch entry. I need to figure out how to make the Edict in the Midwatch entry run just once and then turn itself off. As you may recall, it uses the runCommand action to launch a little Automator app that queries the calendar for the next three days' events, places them on the clipboard, and then a brief AppleScript places the contents of the clipboard into the $Text of the Midwatch entry.

As it happens now, my clipboard is periodically populated with the contents of the next three days' events, which can come as a surprise in the midst of copying and pasting some other text. Fortunately, I have a clipboard history, so I can recover whatever it was I meant to paste.

✍️ Reply by email

Originally posted at Nice Marmot 19:58 Wednesday, 27 March 2024