Michael Van Canneyt wrote:
On Sat, 22 Feb 2014, Mark Morgan Lloyd wrote:

Is it possible to get Format() to pad with leading zeros rather than spaces, particularly in the case of hex numbers? My understanding is that printf() interprets e.g. %02s as being padded with zeros.

For string arguments, this is not possible.

My mistake, I meant %02x.

You can use %.2d for this, or %.2x for hex numbers:

araminta: >./tf
000F
araminta: >cat tf.pp
uses sysutils;

begin
  writeln(format('%.4x',[15]));
end.

Thanks, I now see that is described in the example at http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/format.html but not in the preceding formal documentation.

Reminder noted with thanks.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to