
Programming with VISA
3
Agilent VISA User’s Guide
41
Using Formatted I/O
As noted, the VISA formatted I/O functions are
viPrintf
,
viQueryf
, and
viScanf
.
• viPrintf
formats data according to the format string (
writeFmt
) and
sends the data to a device.
viPrintf
sends separate
arg
parameters,
while the
viVPrintf
function sends a list of parameters in
params
:
viPrintf(
vi
,
writeFmt
[,
arg1
][,
arg2
][, ...]);
viVPrintf(
vi
,
writeFmt
,
params
);
• viScanf
receives and converts data from a device according to the
format string (
readFmt
). The
viScanf
function receives separate
arg
parameters, while the
viVScanf
function receives a list of parameters
in
params
:
viScanf(
vi
,
readFmt
[,
arg1
][,
arg2
][, ...]);
viVScanf(
vi
,
readFmt
,
params
);
• viQueryf
formats and sends data to a device and then immediately
receives and converts the response data. Hence,
viQueryf
is a
combination of both
viPrintf
and
viScanf
functions. Similarly,
viVQueryf
is a combination of
viVPrintf
and
viVScanf
.
viQueryf
sends and receives separate
arg
parameters, while the
viVQueryf
function sends and receives a list of parameters in
params
:
viQueryf(
vi
,
writeFmt
,
readFmt
[,
arg1
]
[,
arg2
][, ...]);
viVQueryf(
vi
,
writeFmt
,
readFmt
,
params
);
Formatted I/O Conversion
Formatted I/O functions convert data under the control of the format
specifier. The format specifier consists of a
%
(percent) symbol, optional
modifier, and a format code. Both
readFmt
and
writeFmt
have the form:
%[modifier]formatCode
Example: Receiving Data From a Session
The following example
uses viScanf to receive data from the session specified by the
vi
parameter and converts the data to a string.
char data[180];
viScanf(vi, "%t", data);
Summary of Contents for E2094S
Page 6: ...6 Agilent VISA User s Guide ...
Page 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Page 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Page 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...