NWprintf

Formats and outputs a string to stdout (parameter reordering is supported)

NetWare Server:4.x, 5.x, 6.x
Platform:NLM, Windows NT, Windows 95, Windows 98
Library:Cross-Platform Localization (LOC*.*)
Service:Internationalization

Syntax

  #include <time.h> or #define NWL_EXCLUDE_TIME 
  #include <stdio.h> or #define NWL_EXCLUDE_FILE 
  #include <nwlocale.h> 
   
  N_EXTERN_LIBRARY_C(nint) NWprintf  ( 
     const nstr N_FAR  *format,  
                       [parameter_1,  
                        parameter_2 ]...); 
  
  

Pascal Syntax

  uses netwin32 
   
  Function NWprintf 
    (const format : nstr, 
     parameter_1, parameter_2, ... 
  ) : nint; 
  
  

Parameters

format
(IN) Points to the format string determining how the data will be formatted before sending it to standard output.
parameter_1, parameter_2,. ..
(IN) Specifies the user-supplied variable list of parameters whose values are used in the formatted output.

Return Values

Returns the number of bytes output.

Remarks

The NWprintf function is the same as the standard C printf with the exception that it supports parameter reordering. This feature allows a language translator to change the order in which arguments are printed by just changing the format string.

There are two ways to do parameter reordering. The most common way is to specify the argument order with a %n in front of each formatting code. For example:

NWprintf("There are %d files in the directory %s.\n", numfiles, dirname);

In an internationalized program, the format string would actually be stored in a separate file to be translated into other languages. The following statement changes the order of the arguments with only a change in the format string:

NWprintf("Directory %2%s contains %1%d files.\n", numfiles, dirname);

The second method allows parameter ordering to be determined at run time. The format string is prepended with a reordering vector specifying the argument order. The reordering vector is a series of bytes with the following format:

LDH!<n><o1><o2><o3>...<format string> <n><o1><o2><o3> etc. are binary bytes.

Where:

<n> is the number of arguments in the printf statements. <o1> specifies which argument should be printed first. If the third argument should be printed first, then <o1> would contain the binary value 3. <o2> specifies which argument should be printed second, etc.

You can also use strings similar to the following:

  printf ("Test: %3$s %2$d %1$s", string, 10, string);
  

See Also

NWsprintf, NWvsprintf, NWvprintf