NOTE: the new support for AppleScript is a complex feature to add to a mature application. It may take time for key features to stabilise and to be able to give canonical code examples (which likely may be done in a resource other than aTbRef). Patience is advised.
Tinderbox offers limited AppleScript support, making it easier to automate workflows with other applications. Explaining general AppleScript functionality is outside the scope of aTbRef but the scripting language is well supported with learning resources both online and in book form.
Some sample expressions that Tinderbox supports include:
set myNote to make new note in document "Workspace.tbx"
set myAgent to make new agent in myNote
This creates a new top-level note, and creates an agent in that note.
set name of myNote to "inbox"
Sets the name of the agent created in the preceding line.
set value of (attribute of myNote named "Width") to 5
Sets the value of an attribute.
get value of (attribute of lastChild of MyNote named "Width")
Fetches the value of the designated attribute. Note the use pf parentheses in this and the preceding example; AppleScript seems to compel this usage.
name of note 3 of document "Workspace.tbx"
Returns the name of the third top-level note in the specified document.
find note in [note or document] with path "/path/to/note"
Returns a reference to the designated note. If the target is a document, the path should be an absolute path. If the target is a note, the path can be an absolute path or a relative path with respect to that note. For example:
find note in myNote with path "parent"
would return a reference to myNote's container.
move myNote to theContainer
moves a note to the specified container
deletes a note.
From v8.0.2, scripts can now create new user attributes.
tell application "Tinderbox 8"
set doc to document "xtest.tbx"
set a to make attribute in doc
set the kind of a to "date"
set the name of a to "myNewAttribute"
The kind of attribute determines the attribute type, and may be any of the following case-sensitive values:
- color (N.B. US spelling)
- URL (N.B. case)
Note that references to attributes specify attributes by name, and so existing references are invalidated after the attribute is renamed. You can get a new reference to the renamed attribute thus:
set a to attribute named "theNewName" in document "theDoc.tbx"
v8.0.3 added support for allowing User attributes to be renamed.
Note: scripts can do very bad things to a document; keep great backups.