Script to format tag as string using engUnit & formatstring properties

Going down the route of binding to each value gets very complicated quickly in my case. At a very high level I’m trying to fill in the data for a table component on the fly based on a mix of generated data and tag values. If the total number of rows was fixed I could plausibly bind at the cell level instead of the whole data table, but I’d have to create a buttload of bindings…

I’m more intrigued by the this post that implies the FormatString is handled by the java.text DecimalFormat class, and the fact that I can do this in the scripting console:

>>> from java.text import DecimalFormat
>>> formatter = DecimalFormat("#,##0.0")
>>> formatter.format(2.1023)
u'2.1'

The actual work of piecing it all together just got much easier…

1 Like