Partly to build a new TBX for daily use, partly as an exercise to learn how to use Tinderbox, I’ve created a new “daily notes” kind of TBX called Captain’s Log
Working from the structure of my blog test platform, I have as Root, the Captain’s Log, which creates the container for the current year. In turn, the year container creates the current month, and the month container creates a daily note which will be the container for each day’s log entries.
The log is intended to be a kind of journal, though it will also record other events.
Ideally, I should be able to make a log entry without being in Tinderbox, much like I can create a Photo post to my blog from Photos.
For now, I’m modifying the Photos script to create a new note in the current day’s container. I have confidence that the script works up to that point. The note is created in the relevant container, but I can’t add the $Name and $Text attributes, which are created via AppleScript dialogs.
This script looks like this (I’m probably missing the proper formatting):
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set entryTitle to display dialog "Entry Title?" default answer ""
copy the result to {button returned:buttonPressed, text returned:titleString}
set entryText to display dialog "Entry Text?" default answer ""
copy the result to {button returned:buttonPressed, text returned:entryString}
tell application "Tinderbox 9"
set this_moment to (the current date)
set nmMonth to (month of this_moment) as string
set nmYear to (year of this_moment) as string
set thePath to "Captain's Log/" & nmYear & "/" & nmMonth & " " & nmYear & "/" & date string of this_moment
tell document "Captain's Log.tbx" -- suffix .tbx required on my machine
-- this is how to specify a note down in the hierarchy:
set theContainer to find note in it with path thePath
set newNote to make new note at theContainer
tell newNote
if entryTitle is not missing value then set value of attribute "Name" to entryTitle
set value of attribute "Text" to entryText
set value of attribute "Prototype" to "p_Entry"
end tell
end tell
end tell
The error I get is this:
But it does create the new entry, just doesn’t populate the attributes. It looks the same as the code I used in the Photos to TBX script, but it’s not working the same.
Once I get this working, I intend to use Automator to turn it into a Quick Action I can assign a keyboard shortcut to, and run it from whatever application I happen to be in.
Further modifications may include log entries of specific emails, attaching Automator actions to Calendar events to create a log entry of a particular Calendar event, and so on. (I will undoubtedly have to ensure only one of my Macs is awake at a time for the Calendar thing. That may be problematic.)
Here is the previous Topic regarding Photos, which yielded a successful, and ongoing, result.
Any help or insight is much appreciated.
Here’s the TBX if you care to look. It’s pretty simple at the moment.
Captain’s Log.tbx (275.1 KB)