Pascal Viandier wrote:
FormatString should be able to do it. It doesn't yet as the current implementation is not much more than a stub (it was done in a hurry ;-).
Is there an example of what FormatString can do already and how to call it? The FormatString entry in the documentation is almost empty and there is no demo program for it.
Not yet (as I said, done in a hurry), only a few test programs, in particular fjf629[efg].pas. But when you understood it, feel free to send us some. :-)
I tried it but found only that the character '%' followed by any letter is used as a place holder for remaining parameters and the letter is not used.
Yes, because GPC has type information itself already, i.e. it's not necessary to distinguish between %s for strings and %i for numbers.
BTW, this part of FormatString is implemented in Pascal (InternalFormatString in p/rts/string2.pas), so perhaps someone who doesn't like C programming might want to help here ...
Reading the source code did not help much. What is the character '@' used for in the format string?
To specify a different argument to write. E.g. %@2s will output the 2nd parameter, instead of the next one. This is sometimes needed in i18n.
BTW, I see that glibc added a different syntax for the same purpose, apparently later than we did, namely %2$s. Perhaps we should consider changing it (e.g., to make things easier for i18n translators), if the %@2s syntax isn't in widespread use yet.
That basically all it does now. As I wrote, it doesn't have padding options yet, though space-padding and precision of reals can be given as in Write statements, e.g. FormatString ('%s', Pi : 10 : 5). (But we should add at least space- and zero padding facilities in the format string, indeed.)
Frank