DADiSP Worksheet Functions > Function Categories > Annotation > NFORMAT
Formats a list of scalars.
NFORMAT("control", arg1, arg2, ..., argN)
"control" |
- |
Format control string. Conforms to C/C++ language sprintf specifications. Control strings may contain ordinary characters, escape sequences, and format specifications. The ordinary characters are copied to the output string in order of their appearance. Escape sequences are introduced by a backslash (\). Format specifications in the control string are introduced by a percent sign (%), and are matched to the specified arguments in order. If there are more arguments than there are format specifications, the extra arguments are ignored. |
||||||||||||||||||||||||||||||||||||||||||||||
argN |
- |
Scalar or string value that matches the control string. For the control string, the Format Specification Fields are specified in the following form: % [flags] [width] [.precision] type
Flags are optional characters that control justification of output and printing of signs, blanks, decimal points, and octal and hexadecimal prefixes. More than one flag can appear in a format specification.
Width is an optional number that specifies the minimum number of characters output.
Precision is an optional number that specifies the maximum number of characters printed for all or part of the output field, or minimum number of digits printed for integer values. The following table indicates the behavior of precision based on type.
Type is a required character that determines whether the associated argument is interpreted as a character, string, or a number.
|
A string.
nformat("Max: %4.2F Min: %4.2F", max, min)
returns a string like "Max: 47.20 Min: 22.03"
NFORMAT is a variation of the SPRINTF function that is constrained to scalars. See SPRINTF for generalized formatting.
See any standard C/C++ language reference for further information.