Format Specifiers Syntax Elements

The following table displays the syntax elements for format specifiers. Refer to the examples of format specifiers for more information.

Syntax Element Description
% Begins the format specifier.
– (optional) Causes the parameter to be left justified rather than right justified within its width.
+ (optional) Used with numeric parameters, includes the sign even when the number is positive.
^ (optional) Used with the e or g conversion codes, uses engineering notation. Precision must be a multiple of 3.
0 (optional) Pads any excess space to the left of a numeric parameter with zeros rather than spaces.
Width (optional) When using a scanning function, specifies an exact field width to use. LabVIEW scans only the specified number of characters when processing the parameter. When using a formatting function, specifies the minimum character field width of the output. This width is not a maximum width. LabVIEW uses as many characters as necessary to format the parameter without truncating it. LabVIEW pads the field to the left or right of the parameter with spaces, depending on justification. If Width is missing or 0, the output is only as long as necessary to contain the converted input parameter.
. Separates Width from Precision.
Precision (optional) Used with floating-point parameters, specifies the number of digits to the right of the decimal point. If Width is not followed by a period, LabVIEW inserts a fractional part of six digits. If Width is followed by a period and Precision is missing or 0, LabVIEW does not insert a fractional part. Used with string parameters, specifies the maximum width of the field. LabVIEW truncates strings longer than this length.
{unit} (optional) Overrides the original unit of a VI when using a function to convert a physical quantity (a value with an associated unit). Must be a compatible unit.
Conversion Codes Single character that specifies how to scan or format a parameter. Conversion characters can be uppercase or lowercase.
d decimal integer (for example, 12)
x hexadecimal integer (for example, B8)
o octal integer (for example, 701)
b binary integer (for example, 1011)
f floating-point number with fractional format (for example, 12.345)
e floating-point number in scientific notation (for example, 1.234E1)
g floating-point number using e format if the exponential is less than –4 or greater than Precision, or f format otherwise
p numeric string in SI prefix notation
s string (for example, abc)
Localization Codes The following codes control the decimal separator used for numeric output. These codes do not cause any input or output to occur. They change the decimal separator for all further inputs/outputs until the next %; is found.
%,; comma decimal separator
%.; period decimal separator
%; system default separator

LabVIEW uses conversion codes to determine the textual format of the parameter. For example, a format specifier of %x converts a hex integer to or from a string.

Use the d, x, o, b, f, e, and g conversion codes to process any numeric LabVIEW data type, including complex numbers, Boolean data types, and enumerated types.

For complex numbers, use the format specifier to process both the real and imaginary parts as a single parameter.

Use the s conversion code to process string or path parameters, Boolean data types, or enumerated types.

Notice that you can use either a numeric or string conversion code with an enumerated type or Boolean type, depending on whether you want the numeric value or symbolic (string) value of the enumerated type.