viVScanf

Agilent VISA.NET

viVScanf

Syntax

viVScanf(ViSession vi, ViString readFmt, ViVAList params);

Description

This function reads, converts, and formats data using the format specifier and then stores the formatted data in params. This function is similar to viScanf, except that the ViVAList parameters list provides the parameters rather than separate arg parameters.

Using viVScanf in Visual Basic 6

The viPrintf, viScanf, and viQueryf VISA functions take variable argument lists in C.  Some of viScanf's and viQueryf's variable arguments are references to primitive (byte, integer, long, float, etc.) types, meaning that the values themselves can be changed by the function.  There is no equivalent in VB6 for variable argument lists with reference arguments, so no direct translation is available.  Instead, use the 'V' form of these functions (viVPrintf, viVScanf, and viVQueryf),  in conjunction with the undocumented VB6 VarPtr function to create an array of pointers to arguments than can be passed to the VISA functions.

The examples below are presented as self-contained VB6 Sub's with comments explaining the various features.  You can modify and adapt the code in the examples to your specific situation.

    • viVPrintf/viVScanf Example using String
    • viVScanf Example Returning a Double Array
    • viVScanf Example Reading an IEEE 488 Definite Length Block and Returning a Byte Array
    • viVScanf Example Reading an IEEE 488 Indefinite Length Block and Returning a Byte Array

Parameters

Name

Dir

Type

Description

vi

IN

ViSession

Unique logical identifier to a session.

readFmt

IN

ViString

The format string to apply to parameters in ViVAList. See viScanf for description.

params

OUT

ViVAList

A list with the variable number of parameters into which the data is read and the format string is applied.

Return Values 

Type ViStatus

This is the function return status. It returns either a completion code or an error code as follows.

Completion Codes

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
VI_ERROR_INV_OBJECT

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.

See Also

viScanf
viVPrintf/viVScanf Example using String

viVScanf Example Returning a Double Array

viVScanf Example Reading an IEEE 488 Definite Length Block and Returning a Byte Array

viVScanf
Example Reading an IEEE 488 Indefinite Length Block and Returning a Byte Array