Description |
The CurrToStrF function converts a currency Value into a displayable string, with great control over the formatting via the Format, and Digits values.
The Digits value determines how many decimal digits are displayed.
The Format parameter is defined by the TFloatFormat (SysUtils) type :
ffCurrency | eg : ?2,345.60
| ffExponent | eg : 2.3456E+04
| ffFixed | eg : 2345.60
| ffGeneral | eg : 2345.6
| ffNumber | eg : 2,345.6 |
Version 2 of this function is for use within threads. You furnish the FormatSettings record before invoking the call. It takes a local copy of global formatting variables that make the routine thread safe.
|
|
Notes |
You can change the currency string from the default (such as '$' in the USA, '?' in the UK) using the CurrencyString variable.
You can change the position of the currency string using the CurrencyFormat variable.
You can change the decimal point value by setting the DecimalSeparator character.
You can change the thousands separator value by setting the ThousandSeparator character.
The NegCurrFormat variable determines the formatting of negative amounts.
If the full number of digits before the decimal point (the mantissa) cannot be displayed, then the display reverts to the exponent (scientific) format.
See FloatToStrF and TFloatFormat for examples of all formatting options. Normally, you would probably use only the ffCurrency format.
|
|
Related commands |
|
|
|
Example code : Display currency numbers as financial values |
var
amount1 : Currency;
begin
amount1 := 1234.567;
// Display in a Currency format
CurrencyString := '? ';
WriteLn('Using 4 digits = '+CurrToStrF(amount1, ffCurrency, 4));
WriteLn('Using 2 digits = '+CurrToStrF(amount1, ffCurrency, 2));
WriteLn('Using 0 digits = '+CurrToStrF(amount1, ffCurrency, 0));
end;
|
Show full unit code |
Using 4 digits = ? 1,234.5670
Using 2 digits = ? 1,234.57
Using 0 digits = ? 1,235
|
|