Tinderbox v8 Icon


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.

Below are some sample expressions that Tinderbox Applescripting now supports. This creates a new top-level note, and creates an agent in that note:

set myNote to make new note in document "Workspace.tbx" 

set myAgent to make new agent in myNote 

Set the name of the agent created in the code above:

set name of myNote to "inbox" 

Set the value of an attribute, here $Width:

set value of (attribute of myNote named "Width") to 5 

Fetch the value of the designated attribute:

get value of (attribute of lastChild of MyNote named "Width") 

Note the use of parentheses in this and the preceding example; AppleScript seems to compel this usage.

Return the name of the third top-level note in the specified document:

name of note 3 of document "Workspace.tbx" 

Return a reference to the designated note:

find note in [note or document] with path "/path/to/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.

Return a reference to myNote's container:

find note in myNote with path "parent" 

Move a note to the specified container:

move myNote to theContainer 

Delete a note:

delete myNote 

From v8.0.2, scripts can create new user attributes.

tell application "Tinderbox 8"

set doc to document "xtest.tbx"

set a to make attribute in doc

set the type of a to "date"

set the name of a to "myNewAttribute"

end tell

The type of attribute (kind pre-v8.0.4) determines the attribute type, and may be any of the following case-sensitive values:

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.

From v8.0.4:

Note: scripts can do very bad things to a document; keep good backups.