table format numbers

Prev Next

Function Names

table format numbers

Description

All numbers in specified columns of the specified table will be identified and formatted according to specifications provided. The mechanism is the same as in the function str() where numbers are provided. Non-numeric data, e.g. text, dates and blank fields, remain unchanged.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

3-4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2
input
table columns Header names and/or column numbers

The specified table columns will be considered for formatting.
See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Any number of header names and column numbers may be specified

3.
input
string Formatting template

Refer to section on numeral to string conversion and formatting

Opt 4.
input
string Locale (formatting option)

Refer to section on numeral to string conversion and formatting, to specify a valid locale,

Opt 5.
input
string Placeholder symbol

Refer to section on numeral to string conversion and formatting, to specify a placeholder symbol.

Examples

  table initialize ( t, { { Product, Price per 100kg, Discount },
      { Apples,  45.5, 0.05 },
      { Oranges, 90.5, 0.10 },
      { Durian,  1240, none } } );

  table format numbers( t, Price per 100kg, "'EUR '?,??0.00", de_DE, '*'  );
  table format numbers( t, Discount, "?0.00 %" );

  table list ( t );

Output

    0 : Product | Price per 100kg | Discount
    1 : Apples  | EUR ***45,50    |  5,00 %
    2 : Oranges | EUR ***90,50    | 10,00 %
    3 : Durian  | EUR 1.240,00    | none    

Try it yourself: Open LIB_Function_table_format_numbers.b4p in B4P_Examples.zip. Decompress before use.

See also

String conversion