Tinderbox v9 Icon

attribute(attributeNameStr).keys


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Function  [other Function type actions]

 Document  [operators of similar scope]

 Document configuration  [other Document configuration operators]

 Baseline

 As at baseline


attribute(attributeNameStr).keys

This returns the attribute dictionary keys for the attribute named in the attributeNameStr argument. Keys are returned in the order listed for attribute(), and not in alphabetical order—as might be intuited. Being a Dictionary operator, it is possible to retrieve all the above as a list of key:value pairs. Note that any attribute name (any valid name) must be supplied as first argument:

$MyList = attribute("Width").keys; 

returns the entire contents of the Dictionary key:value pairs for the attribute Width.

The attribute name can be a variable , so a more useful method is to iterate the list of keys:


var:list vKeys;
var:string vOutput;
vKeys = attribute(anAttribute).keys;
vKeys.each(aKey){
	vOutput += aKey + ": " + attribute(anAttribute)[aKey] + "\n";
};
$Text = vOutput;

By combining with document(), it is possible to make a stamp that creates a listing of all user attributes in the current document, iterate each one, report only keys with a value and place the resulting data in the $Text of the stamped note the stamp code is;


var:list vKeys;
var:string vOutput;
var:list vAttributes = document["user-attributes"];
vOutput += "TBX filename " + document[name] + "\n";
vOutput += "Number of  user attributes: " + vAttributes.count + "\n--------------------\n";
vAttributes.each(anAttribute){
	vOutput += "--------------------\n" + anAttribute + "\n" +"----------\n";
	vKeys = attribute(anAttribute).keys;
	vKeys.each(aKey){
		if(attribute(anAttribute)[aKey] != "" & aKey != "category"){
			vOutput += aKey + ": " + attribute(anAttribute)[aKey] + "\n";
		};
	};
};
$Text = vOutput;