Admin Production ni-theme
Current Publication

Scan

LabWindows/CVI

Scan

int Scan (void *source, char formatString[], ...);

Purpose

Scans a single source item in memory and breaks it into component parts according to format specifiers found in a formatString. Scan then places the components into the target parameter. You can specify up to 29 target arguments.

The Using the Formatting and Scanning Functions section includes a complete discussion of Scan.

Note   This function cannot convert "NaN" and "Inf" to equivalent double-precision numbers.

Parameters

Input
Name Type Description
source void * Specifies the data to be scanned and formatted into the target items.

Refer to the Using the Formatting and Scanning Functions section for more information.
formatString char [] Contains format specifiers that appropriately describe the source and target data to be formatted.

For the three scan functions, the target specifiers must be provided in the format string.

The source specifier may be omitted, in which case the source is assumed to be %s (string). If a source data type other than string is desired, the format string must begin with the specifier of the desired source type, plus the "›" symbol, followed by the target specifiers.

For example, the following calls are equivalent:

x = Scan (s, "%d", i)

x = Scan (s, "%s›%d", i)

The following list includes common specifiers:

%d Indicates that the source or target is an integer.
%i Same as %d.
%f Indicates that the source or target is a double–precision real number.
%s Indicates that the source or target is a string. You may convert numeric values into ASCII form using the %s target specifier.
%10f Indicates that the source or target is an array of ten double–precision real numbers.

Because the data formatting functions can describe many complex formatting operations, refer to the Using the Formatting and Scanning Functions section to make sure you are using the proper format specifier for your application.
Output
Name Type Description
target_s ... Specifies the variables in which to store the scanned items. You can specify up to 29 arguments, and you must separate the arguments with commas. Only the value of the first argument is shown at the bottom of the control after you execute the function panel.

Refer to the Using the Formatting and Scanning Functions section for more information.

Return Value

Name Type Description
ItemsFormatted int Number of target format specifiers satisfied. To get the number of bytes scanned from the source item, call NumFmtdBytes.

If the return value is less than the number of target items, then the source did not contain the exact number and type of items specified in the format string.

This function returns –1 to indicate an error in the format string or –2 to indicate an I/O error.

Additional Information

Library: Formatting and I/O Library

Include file: formatio.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Example

Refer to analysis\stabilty.cws for an example of using the Scan function.