Formatting and I/O Library Chapter 2
LabWindows/CVI Standard Libraries 2-40 © National Instruments Corporation
Fmt, FmtFile, FmtOut—Literals in the Format String
Literal characters appearing in a formatting function format string indicate that the literal
characters are to be combined with the source parameters in the appropriate positions. They do
not correspond to any source parameters, but are copied directly into the target item.
Since the left side of the < symbol must be a single format specifier, literal characters if present
must be on the right side of the symbol. Literals on the left side or more than one format
specifier on the left side result in a -1 error, indicating a faulty format string. You then can use
the function GetFmtErrNdx to determine exactly where the error lies in the format string.
The characters %, [, ], <, and > have special meaning in the format strings. To specify that these
characters be taken literally, they should be preceded by %.
Scanning FunctionsThe following information is a brief description of the three scanning functions.
•n = Scan (source, formatstring, targetptr1, ..., targetptrn);
The Scan function inspects the source argument and applies transformations to it
according to descriptions in the formatstring argument. The results of the
transformations are placed into the targetptr1 ... targetptrn arguments.
•n = ScanFile (handle, formatstring, targetptr1, ..., targetptrn);
The ScanFile function reads data from the file corresponding to the handle argument
and applies transformations to it according to descriptions in the formatstring argument.
The results of the transformations are placed into the targetptr1 ... targetptrn
arguments.
•n = ScanIn (formatstring, targetptr1, ..., targetptrn);
The ScanIn function reads data from standard input and applies transformations to it
according to descriptions in the formatstring argument. The results of the
transformations are placed into the targetptr1 ... targetptrn arguments.
All of the above functions return the number of target format specifiers satisfied. The
function returns a -1 if there is an error in the format string.
The scanning functions break apart a source item into component parts and store the parts into
parameters passed to the function. The only difference between the three functions is the
location of the source data. For the function Scan, the source item is a data item in memory
which is passed to the function. For ScanFile, the source item is a file, whose handle is
passed as the first argument. The handle is obtained by a call to the LabWindows/CVI function
OpenFile. For the function ScanIn, the source is taken from Standard In (typically the
keyboard), and the source argument present in the other two functions is omitted.
All target parameters must be passed by reference.