strFormatby Group Public on Thursday July 02 2009 @ 14:04:32 (1/1 Points) |
|
| API ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
strFormat is used to do simple formatting of values, in particular formatting numbers.
Syntax
The function is exposed with the basic syntax strFormat Format Value and is typically used in an as→ statement.
set %Value% as binOp 10 / 3 set %F% as strFormat 08.3f %Value% Notice %F% # Output is: 0003.333 set %F% as strFormat d %Value% Notice %F% # Output is: 3
Format
The format is a printf like specifier based on the Java String.format↗ function. It has the form (flags)(width)(precision)(conversion)
Conversion
This indicates the basic form the output should have. The supported options are:
- d an integer value
- o an octal integer value
- x a hexadecimal integer value
- e decimal in scientific 'e' notation
- f a decimal value
- g decimal or scientific
- a hexadecimal floating point value
- s string value
Width / Precision
None, one or both may be specified.
The width indicates the total length of the output value. This is a minimum length, so values can exceed this length.
Precision indicates how many decimal positions to display in the final result.
This is based directly on the Java library and unfortunately inherits its oddities relating to width and precision. Make sure you test your formatting to find what works for you.
Flags
These are the commonly used flags:
- - left justify result in specified width
- + always include a sign
- 0 zero pad the result to fit the width
- , use group separators
- ( put negatives in parenthesis
TestPlan strFormat
