Scan From String

Scans the input string and converts the string according to format string.

Use this function when you know the exact format of the input. The input can be string, path, enumerated type, time stamp, or numeric data. Alternatively, you can use the Scan From File function to scan text from a file. The connector pane displays the default data types for this polymorphic function.


icon

Inputs/Outputs

  • cstr.png format string

    format string specifies how to convert the input string into the output arguments.

    The default is to scan the string according to the default format for the data types of the outputs. Formatting a time stamp as anything other than time returns an error. Right-click the function and select Edit Scan String from the shortcut menu to create and edit the format string.

    A space in format string matches any amount of white space, such as spaces, tabs, linefeeds, and form feeds.

    This input accepts a maximum of 255 characters.

  • cstr.png input string

    input string is the string, path, enumerated type, time stamp, or numeric data to scan.

  • cu32.png initial scan location

    initial scan location is the offset into the string where the scan begins.

    The default is 0.
  • cerrcodeclst.png error in

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

  • cdbl.png default value 1

    default 1..n specifies the type and default value for the output parameters.

    If this function cannot scan the input value from format string, the function uses the default. If you do not wire default 1 and you wire a constant to format string, the function uses format string to determine the type of the output. Otherwise, the default data type is double-precision, floating-point. The default value is 0 or an empty string, depending on the output data type. If you wire an enumerated type to default 1, the function finds substrings matching the string values in the enumerated type and returns the corresponding numeric value of the enumerated type.

    You can scan for Boolean values if you use a string or numeric format code. If the format code is %s or unwired, the function reads Y, T, TRUE, ON, or YES and any lowercase versions of those words as TRUE Boolean values. The function reads F, FALSE, OFF, or NO and any lowercase versions of those words as FALSE Boolean values. If you specify a numeric format code, the function reads any numeric value greater than 0.5 as TRUE and any numeric value less than or equal to 0.5 as FALSE.
    Note This function reads negative numbers as FALSE Boolean values because the function converts the number to an unsigned 8-bit integer and any number less than or equal to 0.5 becomes 0 during the conversion.
  • istr.png remaining string

    remaining string returns the portion of the string that remains after scanning all arguments.

  • iu32.png offset past scan

    offset past scan is the offset of input string after completing the scan.

  • ierrcodeclst.png error out

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

  • idbl.png output 1

    output 1..n specifies the output parameters.

    Each output can be a string, path, enumerated type, time stamp, Boolean, or any numeric data type. If you scan a string that does not fit into the numeric data type you specify, this function returns the largest number that fits into that data type. You cannot use arrays and clusters with this function.
  • Increase the number of parameters by right-clicking the function and selecting Add Parameter from the shortcut menu or by resizing the function.

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

    If you set format string to return numeric values in the output parameters, LabVIEW ignores white spaces in the input string.

    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 types you wire to the outputs do not match the types determined by format string, you must change the output types before the VI can run.

    If you do not directly wire a block diagram constant to format string, LabVIEW checks for type mismatches at run time. If you want to scan values that have data types other than double-precision, floating point, you must wire the data types to default 1..n.

    Note By default, this function is locale aware, which means that it uses the system decimal separator configured in the regional settings of the operating system. In some instances, such as using GPIB instruments on European operating systems, you may need to override the system decimal separator by using the localization code syntax elements.

    Examples of Formatting Strings

    Refer to the Format Specifier Syntax topic for more information about and examples of formatting strings.

    input stringformat stringdefault(s)output(s)remaining string

    abc, xyz

    >12.3+56i 7200

    %3s, %s%f%2dabc00
    xyz
    0.00+00i12.30+56.00i
    72
    Q+1.27E–3 tailQ%f t1.27E–3ail
    0123456789%3d%3d12.006789
    345
    X:9.860 Z:3.450X:%fY:%f100 (I32)10Z: 3450
    100.00 (DBL)100.00
    set49.4.2set%d49.4.2
    color: redcolor: %sblue (enum {red, green, blue})red
    abcd012xyz3%[a-z]%d%[a-z]%dabcd
    12
    xyz
    3
    welcome to LabVIEW, John Smith%[^,],%swelcome to LabVIEWSmith
    John

    Time: 23:15:04.25

    5/31/2004

    Time: %<%H:%M:%S%2u%m/%d/%Y>T1/1/1904

    11:15:04.250 PM

    5/31/2004