Viktor,
> cName := "Bond"; cCity := "Tokyo"
> _SPD( "Hi, I'm %#01s from %#02s.", cName, cCity ) -> "Hi, I'm Bond
from Tokyo"
> _SPD( "Hi, I'm from %#02s, my name is %#01s.", cName, cCity ) -> "Hi,
I'm from Tokyo, my name is Bond"
This is TO DO, do you want do it?
My problem is that I have limited time, as we all suppose. :)
ANSI C99 can explicitly specify what argument is taken at each place
where it is needed an argument, writing %m$ instead of % and *m$
instead of %, where the entire decimal m denotes position in the
argument list of desired argument, starting with 1. Therefore,
printf("%*d", width, num); and printf("%2$*1$d", width, num); are
equivalent. The second style allows repeated references to the same
argument. The standard C99 does not allow mixing both styles.
-----------------------
ANSI C99 se puede especificar explícitamente qué argumento se toma, en
cada lugar donde se necesite un argumento, escribiendo `%m$' en lugar de
`%' y `*m$' en lugar de `*', donde el entero decimal m denota la
posición en la lista de argumentos del argumento deseado, empezando por
1. Por tanto, printf("%*d", width, num); y printf("%2$*1$d", width,
num); son equivalentes. El segundo estilo permite referencias repetidas
al mismo argumento. El estándar C99 no permite mezclar ambos estilos.
http://es.tldp.org/Paginas-manual/man-pages-es-1.28/man3/printf.3.html
-----------------------
In my case, the necessity of the function is mount SQL sentences in the
same way that in C with some help.
New functionality or improvements in benefits are welcome: this is Open
Source.
About the name I think it should be the Harbour's community who name,
_SPD is just the name that I have given.
Best regards
Xavi
Szakáts Viktor escribió:
Hi Javier,
One more thing (well two).
IMO to make this function more universal and even easier
to use and update (and usable for someone needing it for
translated text formatting), I think it would very
nice if there would be a possibility to specify the
_ordinals_ of those format strings:
cName := "Bond"; cCity := "Tokyo"
_SPD( "Hi, I'm %#01s from %#02s.", cName, cCity ) -> "Hi, I'm Bond
from Tokyo"
_SPD( "Hi, I'm from %#02s, my name is %#01s.", cName, cCity ) -> "Hi,
I'm from Tokyo, my name is Bond"
[ I seem to recall there is a standard way to achieve this
in printf(), but I didn't find any specifics, so I might be
wrong. ]
To bring this to another level - but this is even more
out of scope of this one function -, it would be great
to have something where you can replace _named_ strings:
_FILL( "INSERT INTO stuff ( stuff_ID, stuff_Name ) VALUES (
%stuff_ID%, %stuff_Name% )",;
{ "stuff_ID" => cStuff_ID, "stuff_Name" => cStuff_Name } )
(or something along this line)
This could be useful for a number of purposes. Basically
a light form of template engine. Maybe it would be best
to mimic some existing standards for the format strings.
Brgds,
Viktor
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour