with an input number = 12345.678
%d (12345)%e (1.23456780000000E+004)%.2f (12345.68)%g (12345.678)%12.2f ( 12345.68) // Just 1 data item
Trace(Format('%s', ['Hello']));
// A mix of literal text and a data item
Trace(Format('String = %s', ['Hello']));
Trace('');
// Examples of each of the data types
Trace(Format('Decimal = %d', [-123]));
Trace(Format('Exponent = %e', [12345.678]));
Trace(Format('Fixed = %f', [12345.678]));
Trace(Format('General = %g', [12345.678]));
Trace(Format('Number = %n', [12345.678]));
Trace(Format('Money = %m', [12345.678]));
Trace(Format('Pointer = %p', [addr(text)]));
Trace(Format('String = %s', ['Hello']));
Trace(Format('Unsigned decimal = %u', [123]));
Trace(Format('Hexadecimal = %x', [140]));
output
Hello
String = Hello
Decimal = -123
Exponent = 1.23456780000000E+004
Fixed = 12345.68
General = 12345.678
Number = 12,345.68
Money = ¤12,345.68
Pointer = 0069FC90
String = Hello
Unsigned decimal = 123
Hexadecimal = 8C
// The width value dictates the output size
// with blank padding to the left
// Note the <> characters are added to show formatting
Trace(Format('Padded decimal = <%7d>', [1234]));
// With the '-' operator, the data is left justified
Trace(Format('Justified decimal = <%-7d>', [1234]));
// The precision value forces 0 padding to the desired size
Trace(Format('0 padded decimal = <%.6d>', [1234]));
// A combination of width and precision
// Note that width value precedes the precision value
Trace(Format('Width + precision = <%8.6d>', [1234]));
// The index value allows the next value in the data array
// to be changed
Trace(Format('Reposition after 3 strings = %s %s %s %1:s %s',
['Zero', 'One', 'Two', 'Three']));
// One or more of the values may be provided by the
// data array itself.
Trace(Format('In line = <%10.4d>', [1234]));
Trace(Format('Part data driven = <%*.4d>', [10, 1234]));
Trace(Format('Data driven = <%*.*d>', [10, 4, 1234]));
output
Padded decimal = < 1234>
Justified decimal = <1234 >
0 padded decimal = <001234>
Width + precision = < 001234>
Reposition after 3 strings = Zero One Two One Two
In line = < 1234>
Part data driven = < 1234>
Data driven = < 1234>
version 7.0.250121
Edit All Pages