% sign (and before the format code letter), zero or more
of the following flags may appear:
#(pound sign) Specifies that the value should be printed using an "alternate format", depending on the format code. For format code(s):
%oA non-zero result will be prepended with
0(zero) in the output.
%XA non-zero result will be prepended with
%GThe result will always contain a decimal point, even if no digits follow it (normally, a decimal point appears in the results of those conversions only if a digit follows). For
%Gconversions, trailing zeros are not removed from the result as they would otherwise be.
%bA non-zero result will be prepended with
0(digit zero) Specifies zero padding. For all numeric formats, the output is padded on the left with zeros instead of spaces.
-(negative field width) Indicates that the result is to be left adjusted in the output field instead of right. A
0flag if both are present. (For the
%Lextended code, this flag indicates the argument is a latitude.)
(a space) Indicates that a space should be left before a positive number produced by a signed format (e.g.
If given with a numeric code, indicates that a sign always be
placed before a number produced by a signed format. A
overrides a space if both are used.
%L extended code, a
+ flag indicates the
argument is a location - latitude and longitude, or geocode.
If given with a string code,
+ indicates that if the string
value exceeds the given precision, truncate the string by a
further 3 bytes, and append an ellipsis ("
can be useful to give an indication of when a value is being
truncated on display. String code support was added in version
<fmt "%#x %#x" 42 0> <fmt "%+d %+d" 42 -42>
0x2a 0 +42 -42
Following any flags, an optional width number may be given. This
indicates the minimum field width to print the value in (unless using
m flag; see Metamorph Hit Mark-up, here).
If the printed value is narrower, the output will be padded with
spaces on the left. Note the horizontal spacing in this example
(output is the right column):
Test results: Test results:
<$x = 42 12345 87654321 912> 42
<LOOP $x> 12345
<fmt "%6d" $x> 87654321
After the width, a decimal point (
.) and precision number
may be given. For the integer formats (
%X), the precision indicates the minimum
number of digits to print; if there are fewer the output value is
prepended with zeros. For the
formats, the precision is the number of digits to appear after the
decimal point; the default is 6. For the
formats, the precision is the maximum number of significant digits
(default 6). For the
%s (string) format, it is the maximum
number of characters to print. Examples:
<fmt "Error number %5.3d:" 5>
Error number 005:
<fmt "The %1.6s is %4.2f." "answering machine" 123.456789>
The answer is 123.46.
The field width or precision, or both, may be given as a parameter
instead of a digit string by using an
* (asterisk) character
instead. In this case, the width or precision will be taken from
the next (integer) argument. Example (note spacing):
<$width = 10> The value is:
<$prec = 2> 123.46
The value is:
<fmt "%*.*f" $width $prec 123.4567>
l (el) flag may appear immediately before the
format code for numeric formats, indicating a short or long value
l has a different meaning for
%:, see here). These flags are for
compatibility with the
printf(), and are not
generally needed in Vortex because integers are automatically promoted
to the largest type available in version 3.01.984500000 20010312 and
later). In these versions, the
w flag may be given to indicate
a "whopping" (largest available, generally 64-bit) value.