LzFormatter

JavaScript: LzFormatter
Formatted output support

See <text>s LzText.format() and Debugs Debug.format() methods for examples of how to present formatted text to the user interface.

Methods

formatToString()
LzFormatter.formatToString(control : String, args);
Formatted output to string Formats its arguments according to the control string. The standard printf conversions are accepted, with the exception of `a`, `n`, and `p`. `e`, `f`, and `g` conversions are accepted but equivalent to `f`. The `h` and `l` length modifiers are accepted but ignored. No errors are signalled for invalid format controls or insufficient arguments. If the Debugger is present, There is an additional format specifier `w` that formats the argument as if by `Debug.__String` with the 'pretty'. If alternate format is requested (#), `w` uses the full `Debug.__String` format used by Debug.write(). `%w` format obeys ???. If a precision is specified, that is used as printLength. When used to format a Debugger message, any Object that is formatted by `s` or `w` will create a link that can be clicked on to inspect the object. There is an additional modifier for the `w` format (=) which will take the next argument as the object to be represented (i.e., linked to) by the formatted string; thus permitting custom representations.
Parameter Name Type Description
control String A control string where % indicates a subsequent argument is to be substituted.
args    
Returns Type Description
  LzMessage the return value is an LzMessage which can be coreced to a string or HTML (the latter supports the hot-linking feature).

pad()
LzFormatter.pad(value : *, widthMin : Number, decMax : Number, pad : String, sign : String, radix : Number, force : Boolean);
pad or trim a string to a specified length
Parameter Name Type Description
value * the value to pad, will be coerced to a string if not a number
widthMin Number the minimum width, if negative pad on the right, default 0
decMax Number for numbers: ensure decimals characters to the right of '.', padding with 0, otherwise maximum width
pad String character to pad on left with, default ' '
sign String ' ', '-', '+', default '-'
radix Number radix to represent numbers in, default 10
force Boolean ensure numbers always have a decimal