utils.stringFormat() Questions

Version: 6.1.3 - build 1424

I am using utils.stringFormat() to create a text-based report and have some questions regarding its capabilities.

Here is the text output that is being generated:

[attachment=1]Current Output.png[/attachment]

Here is the code that generates the output:

var values = [ line_number, index, description, charge, sales_tax ]

utils.stringFormat( '%1$5.0f %2$7s %3$50s %4$8.2f %5$8.2f', values )

This is the desired output:

[attachment=0]Desired Output.png[/attachment]

1st Column: What is the specification (‘%1$5.0f’) to add leading zeros to the ‘line_number’?

2nd Column: What is the specification (‘%3$50s’) to left-justify the ‘description’'?

Any help is greatly appreciated!

Hi Kim,

Googling java.string.format padding gave me the answers.
This formatting string gives the output you are seeking:

utils.stringFormat('%1$05.0f %2$7s %3$-50s %4$8.2f %5$8.2f', values)

Hope this helps.

Yes, that does help…thank you, Robert!