Pascal Viandier wrote:
Pascal Viandier wrote:
Is there a mechanism in GPC to pass a variable number of parameters to a
Pascal
procedure (and to know how many they are?).
No.
I would like to implement something like the C "sprintf()" in Pascal.
Not necessary. WriteStr is built-in already.
There is no description or example for WriteStr entry in the GPC documentation. Is it possible to make something like sprintf(s, "%04d", i) with WriteStr, i.e. with leading zeroes?
Not with WriteStr. Though you could pad with spaces (i : 4), and then replace spaces by zeros (StrReplace in stringutils.pas or your own way).
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 ;-).
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 ...
Frank