oldgrey1 Posted March 29, 2010 Posted March 29, 2010 I can't find any Help on the Format function. It seems to do number of decimal digits. Is there a function to format numbers to display a thousands separator?
AzeoTech Posted March 29, 2010 Posted March 29, 2010 Format() is described in the Expressions Chapter->Expression reference->String functions. It also pretty much follows the standard C printf() statement exactly. No, there is no built in function that displays the thousands separator. You'd have to create your own using script, which shouldn't be too hard. Off the cuff, something like this: function formatThousands(val) if (val >= 1000) return format("%d",floor(val / 1000)) + "," + format("%.3f",val % 1000) else return format("%.3f",val) endif That only works up to 1 million and displays 3 decimals (the "%.3f"). Also, as I said, its off the cuff, so may not work perfectly (for example, won't handle negative values < -1000), but you get the idea.
oldgrey1 Posted March 30, 2010 Author Posted March 30, 2010 Thanks. I am not a coder and need a little more detail here. How does one create a "Function" i.e. where is it written / placed? Is your example the full extent of the code? - assuming the logic presents the correct value.
AzeoTech Posted March 30, 2010 Posted March 30, 2010 Just create a sequence called formatThousands. You can then call it like any other function. For example, at the command / alert window you could type: ? formatThousands(138245.34)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.