July 09, 2004
In article <cbkapi$8nj$1@digitaldaemon.com>, Walter says...
>"Arcane Jill" <Arcane_member@pathlink.com> wrote:
>> One thing I would ask, as it's important in things like localization - can you give us a way to get at the nth, rather than next, parameter. For instance, something like:
>>
>> #    printf("a = %2, b = %1\n", b, a);
>>
>> would print the right values in the right order.
>
>Can you give an example where this would be necessary?

I'm joining in this thread very late, but I've not seen an answer to Walter's question, but Jill raises a valid issue.

In an English message, you would need words in the order <adjective> <noun>. In French, amongst other languages, you would need words in the order <noun> <adjective>.

red fox

renard rouge

If you had messages in a file, and read different files for different languages, but the formatting code was the same for all, then you'd benefit from having the English message containing:

The %1$s %2$s is coming.

And the French message containing:

Le %2$s %1$s arrivant.

(Apologies for the butchered French, lack of accents, and probable problems with gender - but it is a motivational example, not a production system.  A better example would use two nouns - the subject and object of a sentence - where in one language, the best phrase needed the subject to come before the object and another language needed the reverse order.  One of the systems I work on has a feature request for that, but the second language is Korean and I don't know enough Korean to give you a semi-decent example.)

In C, the calling code might be:

snprintf(buffer, sizeof(buffer), fmtstr, adj, noun);

Where buffer is where the output is placed, fmtstr was read from a file and contained the %n$s notations, and adj and noun are variables containing the adjective and noun.  The D notation would be somewhat different - someone better versed in the ways to do it should define that for me.

The POSIX standard for sprintf() et al supports the n$ notation that I used.

See: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html

At the very least, this gives a standardized precedent.

Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
September 18, 2006
can you plz help me doing a program using a TERMINATE STAY
RESIDENT(TSR)....
just only simple program were doing just only indicate our name in the
4 corner of our monitor while we enter the invalid letter or any
keyboard that we press..... plz help me plz we need to submit  it next
week........ TNX 4 reading my message wish and pray that you can help me
doing this program........BYE tnx..........
by the way im RYAN LIM frm  BAUANG, LA UNION a 4th YEAR colleges taking
up a computer engineering........wish you can help me doing this TSR
bye wish you reply as soon as possible if you can.......we use a dos
program a MASM or TASM....
1 2 3 4 5 6 7 8
Next ›   Last »