Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • number - a JavaScript number (or numeric expression) that is to be formatted
  • editCode - character representing an edit code. The following table describes the possible edit codes:

Edit Code DescriptionNo SignCr Sign-Sign(R)-Sign(L)
Commas and zero balances1AJN
Commas2BKO
Zero Balances3CLP
No commas or zero balances4DMQ
Hexadecimal F/D SignX
   



Date editY
 
  



Suppress leading zeroesZ
   

 





Optional Parameters:

  • Length - the number of digits of the formatted number.  If not supplied, the number of significant digits in the number parameter will be used.
  • DecPos - the number of decimal places in the formatted number.  If not supplied, zero will be assumed.
  • CurSym - a currency symbol that will be added to the output.  If not supplied, no symbol is added.
  • Options - a JavaScript object with additional formatting options, described below.

...

  • dateEdit - date (edit code Y) style for 8-digit numbers.  Can be *ymd for xxxx/xx/xx.  If not specified, xx/xx/xxxx is used.
  • dateEditSeparator - separator used in date (edit code Y) output.  If not specified, the / character is used as a separator.
  • decimalEdit - Editing control for decimal numbers.  Possible values are follow:
    • "." - use period for decimal separator, do not show a leading zero on fractions (default)
    • "," - use comma for decimal separator, do not show a leading zero on fractions
    • "0." - use period for decimal separator, show a leading zero before fractions
    • "0," - use a comma for decimal separator, show a zero before fractions

Examples:

Code Block
themeEclipse
languagejavascript
var val0 = 1000;
pui.editCode(val0, "J");                               // "1,000  "
pui.editCode(val0, "J", "$");                          // "$1,000 "
pui.editCode(val0, "J", 9, 2);                         // "    1,000.00 "
pui.editCode(val0, "J", 9, 2, "$");                    // "    $1,000.00 "
pui.editCode(val0, "J", 9, 2, { decimalEdit: "," });   // "    1.000,00 "

var val1 = "-25";
pui.editCode(val1, "1", 9, 2);                         // "      25.00"
pui.editCode(val1, "A", 9, 2);                         // "      25.00CR"
pui.editCode(val1, "J", 9, 2);                         // "      25.00-"
pui.editCode(val1, "N", 9, 2);                         // "      -25.00"

var val2 = 0.5;
pui.editCode(val2, "P");                               // " 0.5"
pui.editCode(val2, "P", 9, 2, { decimalEdit: "." });   // "       .50"
pui.editCode(val2, "P", 9, 2, { decimalEdit: "," });   // "       ,50"
pui.editCode(val2, "P", 9, 2, { decimalEdit: "0." });  // "      0.50"
pui.editCode(val2, "P", 9, 2, { decimalEdit: "0," });  // "      0,50"

 

 

...




This function first appeared in Profound UI 5.13.0