National Instruments 320682C Musical Toy Instrument User Manual


 
Formatting and I/O Library Chapter 2
LabWindows/CVI Standard Libraries 2-36 © National Instruments Corporation
the integer is converted to a string format. You can enter any non-negative value
here. If n is less than the number of digits required to represent the integer, an
asterisk (*) will be inserted into the string to signify an overflow. The default for
n is zero, which indicates that the integer can occupy whatever space is necessary.
pc Specify Padding. The p integer modifier specifies a padding character c, which
fills the space to the left of an integer in the event it does not require the entire
width specified with the w
n
modifier. The default padding character is a blank.
s Specify as Two’s Complement. The s integer modifier indicates that the integer
argument is considered a signed two's complement number. This is the default
interpretation of integers, so the s modifier is never explicitly required.
u Specify as Unsigned. The u integer modifier indicates that the integer is
considered an unsigned integer.
onnnn Specify Byte Ordering. The o integer modifier is used to describe the byte
ordering of raw data so that LabWindows/CVI can map it to the byte order
appropriate for the Intel (PC) or Motorola (SPARCstation) architecture. The
number of
n
's must be equal to the byte size of the integer argument as specified
by the b
n
modifier, which must precede the o modifier. In the case of a four-byte
integer, o0123 indicates that the bytes are in ascending order of precedence (Intel
style), and o3210 indicates that the bytes are in descending order of precedence
(Motorola style).
In a Fmt function, the buffer containing the raw instrument data should have the
o modifier describing the byte ordering. The buffer without the o modifier is
guaranteed to be in the mode of the host processor. In other words,
LabWindows/CVI will reverse the byte ordering of the buffer without the
o modifier depending on which architecture the program is running on.
For example, if your GPIB instrument sends two-byte binary data in Intel byte
order, your code should appear as follows:
short int instr_buf[100];
short int prog_buf[100];
status = ibrd (ud, instr_buf, 200);
Fmt (prog_buf, "%100d<%100d[b2o01]", instr_buf);
If, instead, your GPIB instrument sends two-byte binary data in Motorola byte
order, the Fmt function should appear as follows:
Fmt (prog_buf, "%100d<%100d[b2o10]", 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.