Tinderbox Forum

AS (Apple Script) app to add attributes to TBX

I’m working on my “architecture” to have a reusable set of action code functions. If I copy a function to a new TBX file I run into the problem that I need to create the user attributes used in the function manually. So I created a small AS app that will solve this issue for me.

addTBXAtt.zip (56.9 KB)

This is an AppleScript app with the source included - you can open it with the Script Editor if you like.
if you don’t like to jump into the AS world - just place the app anywhere on your Mac, copy the path to the app and enter this action code in TBX:

$MyString = runCommand("osascript ~/Desktop/addTBXAtt.app 'FirstAttribute:string;SecondAttribute:number'");

A good place may be a stamp - since you need to run it only once. The parameter is a string containing any number of attributes to be created. Its “name:type” separated by a “;”.

Maybe useful for someone :wink:

P.S.: The hard thing to solve were some security issues I ran into on my Mac. The security settings are getting weird in the current Mac OS releases…


Love this. Here is a nice add on. Let’s say your want to get a list of all the attributes you use in a file. So that you can pull out a list of attribute:type pairs to add to @webline’s stamp above. Do this:

  1. Open your file
  2. Create this stamp
var vAttrList = document["user-attributes"];
$Text =;
$Text = "Number of user attributes: " + vAttrList.count + "\n";
   var vAttrKeys = attribute(anAttr)["type"];
	$Text = $Text+"\n"+ anAttr +":"+ vAttrKeys+ ";";
  1. Create a note, call it “MyAttributres” (the name does not matter)
  2. Apply the stamp in step 2 above to the note created in step 3.
    You’ll get something like this:

You can then manually go through the list and pull out the attributes you want to create in your standard stamp.


so with two functions it will be easy to move functions, notes including all user attributes to a new TBX file:

function getAllUserAttributes_db(){
	// write all user attributes to a note
	var vAttrList = document["user-attributes"];
	$Text =;
		var vAttrKeys = attribute(anAttr)["type"];
		$Text = $Text + anAttr + ":" + vAttrKeys + ";";

function createUserAttributes_db(theAttributes){
	// call the external AS app and pass all attributes you need
	// you may use the content of the $Text created with getAllUserAttributes_db()
	// make sure you add the correct path to the AS app here!!!
	var createAttCommand = "osascript ~/Documents/Tinderbox/addTBXAtt.app '" + theAttributes + "'";
	$MyString = eval("runCommand(createAttCommand)");
1 Like

Is there a way to pull the list of attributes from the $Text of a note? I’d love to be more selective in the attributes I pull over, not all the attributes in a file.

call createUserAttributes_db($Text) with the content of a note you select - for example the note you filled with getAllUserAttributes_db() and copied to the new file.
createUserAttributes_db(Attributlist:string) takes whatever you pass as long as the format is “name:type;” - this includes the text content of a note stored in $Text

1 Like

on request I added the option to pass a 3rd parameter for an attribute → the DefaultValue for that attribute. So if you pass an attribute to the AS app:

“AttName:AttTyp:AttDefault” or “AttName:AttTyp”

would do it. Like: “MyNewAttribute:string:one small step” or “MyNewAttribute:string” both would create the attribute $MyNewAttribute.

addTBXAtt2.zip (57.2 KB)


@webline—Thank you for the AppleScript. This works just as you described it, and I’ve tried the various patterns of usage with your 2nd version as well as some of the edge cases with no problems. I particularly like that you provide some error reporting. I am also running on macOS 12 (Monterey), and I was initially concerned that Apple’s security enhancements would cause problems, but that was not the case. This just worked.

I will update my Logging Toolbox to provide this as an option for incorporating logging into an existing document.

Nicely done…