Tinderbox v10 Icon

Attributes

Attributes are an element of the document object, though they may hold/inherit a value at the scope of a note object.

User Attributes

Scripts can create new user attributes:


   tell application "Tinderbox 8"
      set doc to document "xtest.tbx"
      set newAttr to make attribute in doc
      set the type of newAttr to "date"
      set the name of newAttr to "myNewAttribute"
   end tell

Or, to test for an attribute before use, and make it if not found:


tell front document
   -- check URL type attribute $HookURL exists or make one
   try
      set hookTest to attribute named "HookURL"
   on error errMsg number errNum
      set newAttr to make attribute
      set the type of newAttr to "url"
      set the name of newAttr to "HookURL"
      set hookTest to attribute named "HookURL"
   end try
end tell

Be aware that when using make new attribute, if a user attribute already exists with the designated name, the existing attribute is modified. If a system attribute already exists with the same name, no changes are made and no attribute is created. Therefore it is best to test for an attribute's existence before (re-)making it.

user attributes may be accessed as a list:

set userList to user attributes of front document 

User attributes may be renamed. 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:


tell front document
   set attrRef to attribute named "OldName"
   set name of attribute "OldName" to "NewName"
   set attrRef to attribute named "NewName"
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: action, boolean, color (N.B. US spelling), date, dictionary, email, file, font, interval, list, number, set, string, URL (N.B. case)—i.e. any of the currently defined Tinderbox attribute data types.

Attributes have a read-only property, 'category', that groups related attributes to their attribute Group as seen in Get Info. The category of renamed and deprecated attributes is returned as the category of their replacement.