Util.FormatFloat |
Top Previous Next |
Syntax function Util.FormatFloat(FormatStr: string; FloatValue: float): string
Alternative Names
Description Formats the given FloatValue according to the format as specified in FormatStr.
Returns a string with a formatted floating point value.
The following table shows some sample formats and the results produced when the formats are applied to different values (Windows regional settings have '.' as the decimal separator and ',' as the thousand separator):
The decimal separator and thousand separator are taken from the Control Panel and can be modified using Util.SetSystemText.
See Also
Example execute UDSBlock as begin /* outputs 1234.00 */ floatstr_alwaysdecimals = Util.FormatFloat('0.00', 1234); /* outputs 1234 */ floatstr_nodecimals = Util.FormatFloat('#.##', 1234); GUI.ShowMessage('With specified decimals: ' || floatstr_alwaysdecimals || String.CRLF() || 'Without specified decimals: ' || floatstr_nodecimals);
/* outputs 1234.05 */ floatstr1 = Util.FormatFloat('0.00', 1234.05); /* outputs 1234.05 */ floatstr2 = Util.FormatFloat('#.##', 1234.05); GUI.ShowMessage('With specified decimals: ' || floatstr1 || String.CRLF() || 'Without specified decimals: ' || floatstr2);
/* outputs -1234.05 */ floatstr1 = Util.FormatFloat('0.00', -1234.05); /* outputs (1234.05) */ floatstr2 = Util.FormatFloat('0.00;(0.00)', -1234.05); GUI.ShowMessage('Positive & negative have some format: ' || floatstr1 || String.CRLF() || 'Negative specific format: ' || floatstr2);
Util.SetSystemText(__sysDecimalSeparator, ','); floatstr1 = Util.FormatFloat('0.00', 1234.05); GUI.ShowMessage('Changed decimal separator: ' || floatstr1); end |