Tinderbox Forum

Use an attribute type in a conditional argument

Is there a way to use the attribute type in a conditional argument? I have some export code that is generated attribute references on the fly. I would like to be able to test if $Attribute is Type “Date” then { } else {}.

Is something like this possible?

As just discussed offline, but for readers here, in short no. It has been requested (IIRC, I did via email or on the Backstage).

One might ask why, when we already know the data type of any attribute defined for the current document. the issue arises when recreating a table like Displayed Attributes during export in a manner that doesn’t need to know each row item in advance. One can do this by using $Displayed Attributes.each(){} and iterating out each current note. So far, so good. But different attribute data types need different (or no) formatting and all we have is the name of the attribute. For example, the name might be SomeAttribute. We want to format a Date differently from a Boolean or List or String, etc. But we have no way—via action code—to ask the data type of the attribute SomeAttribute.

This is quite advanced action/export stuff, but is a missing piece of glue. The current kludge is to write a look-up for each discretely formatted data type with the names of likely-used attributes which are of that type and test each list item against each of the data types.