NoteCase Pro is my choice when it comes to note keeping applications. This is a powerful cross-platform application that contains an impressive set of built-in features, but also provides a mechanism for extending the functionality via plugins and user scripts in the Lua scripting language.
While reading or working on a note I often need to be aware of the date when the note was first created or last modified. NoteCase Pro keeps this information in the notes database and the UI can be configured to present these dates in the note tree, but I wanted a solution that doesn’t clutter the interface. So I wrote a short Lua script that displays these dates in the status bar.
The script makes a few calls to the NoteCase API and formats the output in the desired way:
-- get IDs for the current document and note and store as variables nDocID = Nc_Doc_ID_GetCur() strNoteID = Nc_Note_ID_GetCur(nDocID) -- get the dates strDateCreated = Nc_Note_DateCreated_Get(nDocID, strNoteID) strDateModified = Nc_Note_DateModified_Get(nDocID, strNoteID) -- Format the output string -- The string below would use the default timestamp format: yyyy.mm.dd hh:mm:ss -- strOut = "Created: " .. strDateCreated .. ", Last Modified: " .. strDateModified -- Let's convert to a more readable format -- First parse the captured timestamps pattern = "(%d+).(%d+).(%d+) (%d+):(%d+):(%d+)" crtYear, crtMonth, crtDay, crtHour, crtMinute, crtSeconds = strDateCreated:match(pattern) modYear, modMonth, modDay, modHour, modMinute, modSeconds = strDateModified:match(pattern) -- Then form the output string strOut = "Created: " .. crtDay .. "/" .. crtMonth .. "/" .. crtYear .. " ..... Last Modified: " .. modDay .. "/" .. modMonth .. "/" .. modYear -- Finally, show status bar message in black text Nc_GUI_StatusBarMessage(strOut)
We save the script in a text file somewhere in the file system. The script gets registered by the application in the Script Manager dialog (Add-ons -> Script Manager).
Scripts can be mapped to Script Events, which would get them invoked by the application on specific events. My initial idea was to assign my script to the ‘After note focused’ event so that the dates would get printed on the status bar whenever a new note is displayed, but alas, NoteCase overwrites the status bar with some information after this event.
So instead of mapping my script to an event, I assigned it a shortcut key in the Shortcut Settings dialog (Tools -> Shortcut settings). This way, whenever I want to inspect the note creation and last modification date of the presented note I press the shortcut combination and the dates get shown in the status bar.
It is also possible to add a button to the toolbar through the Toolbar Settings dialog (Tools -> Toolbar Settings) by copying the corresponding ‘Lua script’ entry from the ‘Available actions’ list to the ‘Toolbar layout’ list.