Chapter 2 Formatting and I/O Library
© National Instruments Corporation 2-45 LabWindows/CVI Standard Libraries
short int instr_buf[100];
short int prog_buf[100];
status = ibrd (ud, instr_buf, 200);
Scan (instr_buf, "%100d[b2o01]>%100d", prog_buf);
If, instead, your GPIB instrument sends two-byte binary data in Motorola byte order,
the Scan function should appear as follows.
Scan (instr_buf, "%100d[b2o10]>%100d", prog_buf);
In either case, the o modifier is used only on the buffer containing the raw data from
the instrument (instr_buf). LabWindows/CVI will ensure that the program buffer
(prog_buf) is in the proper byte order for the host processor.
Note: When using both the bn and on modifiers on an integer specifier, the bn modifier
must be first.
Scanning Floating-Point Modifiers (%f)
bn Specify Length. The b floating-point modifier specifies the length of the
floating-point argument, or the length of an individual array element, in bytes. The
default length is 8 B; therefore, double-precision values do not need this modifier.
Single-precision floating-point values are indicated by b4. 8 and 4 are the only valid
values for
n
.
in Specify Array Offset. You can use the i floating-point modifier to specify an offset
within a floating-point array argument. It indicates the location within the array
where processing is to begin.
n
is the zero-based index of the first element to process.
Thus, %10f[i2] applied to a source floating-point array reads the 10 floating-point
values from the third through the twelfth elements of the array. The i modifier is
valid only if rep is present. If you use the i modifier with the z modifier, then n is
in terms of bytes.
zTreat String as Floating Point. The z floating-point modifier indicates that the data
type of the corresponding argument is a string. Nevertheless, the data in the string is
treated as a floating-point array. The z modifier is valid only if rep is present.
wn Specify String Size. The w floating-point modifier specifies the exact number of
bytes occupied by a string representation of the floating-point argument, in the event
that the value is converted from a string format. You can enter any non-negative
value here. If
n
is less than the number of digits required to represent the
floating-point number, an asterisk (*) will be inserted into the string to signify an
overflow. The default for
n
is zero, which indicates that the value can occupy
whatever space is necessary.
pn Specify Precision. The p floating-point modifier specifies the number of digits to the
right of the decimal point in a string representation of the floating-point number.
Significant digits may be lost in attempting to conform to the precision specification.