[fpc-pascal] format string - number padding

ik idokan at gmail.com
Mon Jan 9 12:24:03 CET 2012


On Mon, Jan 9, 2012 at 13:17, Sven Barth <pascaldragon at googlemail.com>wrote:

>
> Am 09.01.2012 12:08 schrieb "ik" <idokan at gmail.com>:
>
> >
> > Hello,
> >
> > I'm trying to use the Format function to pad a number like so:
> > 01
> > where the original value is "$1".
> >
> > I tried to do the following:
> >
> > writeln(Format('%02X', [$1]));
> > writeln(Format('%0:2X', [$1]));
> > writeln(Format('%:2X', [$1]));
> >
> > All of them created the following output:
> > " 1"
> >
> > What am I doing wrong ?
>
> You tried nearly everything except %.2X :)
>
> See also the examples here:
> http://www.freepascal.org/docs-html/rtl/sysutils/format.html
>

Thanks. It's a bit difference then C and few other languages :(


>  Regards,
> Sven
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120109/07cfbce7/attachment.html>


More information about the fpc-pascal mailing list