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.


icon

Inputs/Outputs

  • cstr.png format string

    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 \\.
  • cstr.png initial string

    initial string specifies the base string to which you can append any arguments to form the resulting string.

  • cerrcodeclst.png error in

    error in describes error conditions that occur before this node runs. This input provides standard error in functionality.

  • cdbl.png input 6

  • istr.png resulting string

    resulting string contains the concatenation of initial string and the formatted output.

  • ierrcodeclst.png error out

    error out contains error information. This output provides standard error out functionality.

  • 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.

    Examples

    Refer to the following example files included with LabVIEW.

    • labview\examples\File IO\Spreadsheet\Tab-Delimited Data\Buffered Stream to Tab-Delimited Text File.vi