Syntax
Syntax
viScanf(int vi, string readFmt, <overloaded parameter>);
Description
This operation receives data from a device, formats it by using the format string, and stores the data in the overloaded argument variable. The format string can have format specifier sequences, white space characters, and ordinary characters.
For information about getting more options in the parameter list, see Advanced Use of viPrintf/viScanf.
Parameters
Name |
Dir |
Type |
Description |
vi |
IN |
int |
Unique logical identifier to a session. |
readFmt |
IN |
string |
String describing the format for arguments. |
overloaded argument |
OUT |
N/A |
A list with the variable number of parameters into which the data is read and the format string is applied. |
Return Values
Completion Code |
Description |
VI_SUCCESS |
Data were successfully read and formatted into arg parameter(s). |
Error Codes |
Description |
VI_ERROR_ALLOC |
The system could not allocate a formatted I/O buffer because of insufficient resources. |
VI_ERROR_INV_FMT |
A format specifier in the readFmt string is invalid. |
VI_ERROR_INV_SESSION |
The given session or object reference is invalid (both are the same value). |
VI_ERROR_IO |
Could not perform read function because of I/O error. |
VI_ERROR_NSUP_FMT |
A format specifier in the readFmt string is not supported. |
VI_ERROR_RSRC_LOCKED |
Specified operation could not be performed because the resource identified by vi has been locked for this kind of access. |
VI_ERROR_TMO |
Timeout expired before read function completed. |
C# Example
public int ReadDefiniteLengthBinaryBlockAsInt32(int session, int maxElementCount, int[] data) { int viError, elementCount = maxElementCount; viError = visa32.viScanf(session, "%#lb", ref elementCount, data); if (viError < visa32.VI_SUCCESS) { System.Text.StringBuilder error = new System.Text.StringBuilder(256); visa32.viStatusDesc(session, viError, error); throw new ApplicationException(error.ToString()); } return elementCount; }
VB .NET Example
Public Function ReadDefiniteLengthBinaryBlockAsInt32(ByVal session As Integer, _ ByVal maxElementCount As Integer, _ ByVal data() As Integer) As Integer Dim viError As Integer, elementCount As Integer = maxElementCount viError = visa32.viScanf(session, "%#lb", elementCount, data) If viError < visa32.VI_SUCCESS Then Dim err As System.Text.StringBuilder = New System.Text.StringBuilder(256) visa32.viStatusDesc(session, viError, err) Throw New ApplicationException(err.ToString()) End If Return elementCount End Function