In a large project, it is easy to generate tens—hundreds—of user attributes … and then forget why you added them when returning later to the project to do new work. In the ideal world we add a description when creating the attribute. But, the Displayed Attributes configurator helpfully makes user attributes for you on the fly—useful, to avoid braking flow—but that bypasses seeing the new attribute in the Inspector.
Opening a research project this AM, I wondered how many user attributes there are and how many lack descriptions. I could have recorded only those attributes for which the attribute(attrName)["description"]
was empty but as I wanted a list of descriptions to read, it made sense to do the latter and edit any attributes found with no description text.
In my experiment, I found I had 133(1)m user attributes, 5 without descriptions and 12 with typos in the descriptions. I now have 113 descriptions and no typos. A useful task done!
To do the above, I make a new note and give it this code (I used an edict (a rule is overkill for this):
var:string vOutput=;
var:list vNameList = document["user-attributes"];
$Text = "There are " + vNameList.count + " user attributes.\n\n";
vNameList.each(aName){
vOutput += aName + "\n";
vOutput += attribute(aName)["description"] + "\n\n";
};
$Text += vOutput;
… and we get $Text ike so:
To make this more portable you could use a function instead:
function fUserAttributeDescriptions(){
var:string vOutput=;
var:list vNameList = document["user-attributes"];
vOutput = "There are "+vNameList.count+" user attributes.\n\n";
vNameList.each(aName){
vOutput+=aName+"\n";
vOutput+=attribute(aName)["description"]+"\n\n";
};
return vOutput;
} // END
called from any note like so:
$Text = fUserAttributeDescriptions();
If writing (exported) reports for others and using attribute names in the report, or the reports describe the data extraction/analysis process done in Tinderbox, being able to export these descriptions might be useful. If the case, then make a variant of the function like so:
function fUserAttributeDescriptionsHTML(){
var:string vOutput=;
var:list vNameList = document["user-attributes"];
vOutput = "<p>There are "+vNameList.count+" user attributes.</p>\n";
vNameList.each(aName){
vOutput+="<h4>" + aName + "</h4>\n";
$Text(/log) = attribute(aName)["description"];
vOutput+=exportedString(/log,"^text^")+"\n";
};
$Text(/log)=;// clear log
return vOutput;
} // END
As exportedString
must use a note object as the source data, I’ve added a ‘log’ note to the root of the document’s outline. The description data it written to that note’s $Text and the ^text^ evaluated for the export and at the end the /log
file $Text is emptied so as not to leave cruft to build up.
Now your export template simply calls:
^value(fUserAttributeDescriptionsHTML())^
…and your HTML marked-up list data is exported.