.NPRINT - formatted output to a string.

Usage:

B:
  i = .nprint( s, N, format [, arg1, arg2, ...] );
/* C users use "snprintf" */

Where:

s
points to the memory area where the output should be written.
N
is an integer giving the maximum number of characters that can be written to "s" (including a '*0' to mark the end of the string). If N is zero, the "s" pointer may be null.
format
is a "printf-style" format string.
arg1, arg2, ...
are the values to be output.
i
is an integer telling the number of characters that would have been output if N was sufficiently large to permit the entire string. This count does not include the '*0' used to mark the end of the string. If a write error occurs, a negative number is returned.

Description:

.NPRINT writes to the string "s". The function converts, formats, and prints its arguments under control of the string "format". For a full description of the formatting used by .NPRINT, see the documentation for "printf".

The value N specifies the maximum number of characters to be written into the output string, including the '*0' on the end. This means that if the formatted output string is longer than N-1 characters, characters beyond the N-1'st character are discarded and a '*0' character is placed at the end of the string.

Note that .NPRINT returns the number of characters that would have been printed if there was enough room. This means, for example, that in some cases it might be useful to call .NPRINT twice:

See Also:

expl b lib printf

expl c lib snprintf

Copyright © 2000, Thinkage Ltd.