Difference between revisions of "Format"
From SCAR Divi Manual
(Created page with "==Definition== <source lang="scar" lines="false"> function Format(s: AnsiString; data: array of const): AnsiString; </source> ==Availability== SCAR Divi 3.20 > Current ==Descri...") |
(No difference)
|
Revision as of 08:56, 2 July 2011
Contents
Definition
function Format(s: AnsiString; data: array of const): AnsiString;
Availability
SCAR Divi 3.20 > Current
Description
Format replaces special formatting substrings in a given string s with the data provided by the given array data, they are replaced in the order that they are defined in s. The format of each substring is given as "%[Index:][-][Width][.Precision]Type".
Type Indicators
- %d: An integer value
- %e: Scientific notation
- %f: Fixed point notation
- %g: Regular notation
- %m: Currency notation
- %n: Floating point notation
- %s: A string value
- %u: Unsigned integer notation
- %x: Hexadecimal notation
Example 1[1]
begin WriteLn(Format('Decimal = %d', [-123])); WriteLn(Format('Exponent = %e', [12345.678])); WriteLn(Format('Fixed = %f', [12345.678])); WriteLn(Format('General = %g', [12345.678])); WriteLn(Format('Number = %n', [12345.678])); WriteLn(Format('Money = %m', [12345.678])); WriteLn(Format('String = %s', ['Hello'])); WriteLn(Format('Unsigned decimal = %u', [123])); WriteLn(Format('Hexadecimal = %x', [140])); end.
Output:
Decimal = -123 Exponent = 1,23456780000000E+004 Fixed = 12345,68 General = 12345,678 Number = 12.345,68 Money = € 12.345,68 String = Hello Unsigned decimal = 123 Hexadecimal = 8C
Example 2
begin WriteLn(Format('%.2f', [12345.6789])); WriteLn(Format('%.10d', [12345])); WriteLn(Format('%10d', [12345])); end.
Output:
12345,68 0000012345 12345