Format Into String Function

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

Owning Palette: String Functions

Requires: Base Development System

Formats string, path, enumerated type, time stamp, Boolean, or numeric data as text.

You can use the Format Into String function to convert a number into a string. To format data as text and write the text to a file, use the Format Into File function instead.

Details  Example

format string specifies how you want the function to convert the input arguments into resulting string. Defaults match the data type of the input arguments. Right-click the function and select Edit Format String from the shortcut menu to create and edit the format string. Use special escape codes to insert non-displayable characters, the backslash, and the percent characters.
Note  This function interprets backslashes as escape characters. To use a literal backslash in format string, you must enter \\.
initial string specifies the base string to which you can append any arguments to form the resulting string.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
input 1..n specifies the input parameters you want the function to convert. This parameter accepts a string, path, enumerated type, time stamp, Boolean, or any numeric data type. For complex numeric data types, this function converts only the real component. You cannot use arrays and clusters with this function. You can specify up to 4,096 characters for each input.

If you specify a Boolean value for this parameter and %s as the format code, the Format Into String function outputs the value as TRUE or FALSE. If you specify a Boolean value for this parameter and any numeric format code, the Format Into String function outputs the appropriate version of 1 for TRUE and 0 for FALSE. For example, if you specify %f as the format code, the function outputs 1.00000. If you specify %d, the function outputs 1.
resulting string contains the concatenation of initial string and the formatted output.
error out contains error information. This output provides standard error out functionality.

Format Into String Details

To increase the number of parameters, right-click input 1 and select Add Parameter from the shortcut menu or resize the function.

Note  If an error occurs, the error out cluster element source contains a string of the form Format Into String (arg n), where n is the first argument for which the error occurred.

If you wire a block diagram constant string to format string, LabVIEW uses format string to determine the number of outputs and the data type of each output at compile time. If the data types you wire to the outputs do not match the data types determined by format string, you must change the output data types before the VI can run.

Specifying Which Input to Use within the Format String

By default, this function uses the order of the inputs to populate the format specifiers, or percent codes in the Format String. However, you can use a number followed by a dollar sign ($) within a percent code to specify exactly which input to use for that percent code. For example, the percent code %3$d uses the third input regardless of how many percent codes appear before %3$d in the format string.

Refer to the following block diagram and table for an example of how to use format specifiers:

The following input combinations illustrate the effects of the $ specifier in the previous block diagram:

Input 1Input 2Format StringReturn StringComments
firstsecond%s %sfirst secondFormat String does not use the $ specifier, so the function populates the percent codes in input order.
firstsecond%2$s %1$ssecond firstFormat String uses the $ specifier to display the inputs in a different order than their input order.
firstsecond%1$s %1$s %1$sfirst first firstFormat String uses the $ specifier to display the first input multiple times and ignore the second input.

You can use other special characters besides the $ to configure how this function populates the percent codes in format string.


Refer to the Buffered Stream to Tab-Delimited Text File VI in the labview\examples\File IO\Spreadsheet\Tab-Delimited Data directory for an example of using the Format Into String function.


Not Helpful