-----Message d'origine----- De : gpc-owner@gnu.de [mailto:gpc-owner@gnu.de] De la part de Frank Heckenbach Envoyé : March 14, 2006 11:37 À : gpc@gnu.de Objet : Re: RE : Variable number of parameters
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 ;-).
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. 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.
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?
Regards
Pascal Viandier
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8