This osascript
library is excellent – particularly for use from AppleScript.
Anyone more accustomed to using osascript -l JavaScript
than osascript -l AppleScript
may bump into the familiar gap, which Apple never filled, in the implementation of location specifiers
for the JS interface.
Where, for example, your very helpful example code at:
AppleScript - Bike
shows:
make child row at front
the JS implementation of an osascript
interface doesn’t offer us an equivalent of at front
, and we can, by default, only insert new objects at the end of collections from JavaScript.
We can get around this, in practice, in various ways, not least by evaluating a tiny AppleScript snippet inline from JS, but I wonder how feasible it might look to implement a pair of osascript
methods like:
(perhaps accepting row id arguments ?) which don’t need osascript location specifiers
, and could thus used from JS as well as from AS ?
At the moment, a JS version of your sample:
https://bikeguide.hogbaysoftware.com/applescript#today-script
can be readily written if want to put the new indented rows at the end of a document, but requires some additional thought and gymnastics to insert them at the top of a document using JS
Far from urgent or essential, but at some point, if it looked feasible, some analogue of the TaskPaper
Item.insertChildrenBefore(children, referenceSibling?)
, or
Outline.insertItemsBefore(items, referenceItem)
would simplify placing new rows from JS.