Syntax

Agilent VISA.NET

Syntax

Syntax

viPrintf(int vi, string writeFmt, <overloaded arguments>);

Description

This function converts, formats, and sends the overloaded parameter argument to the device as specified by the format string. Before sending the data, the function formats the overloaded argument variable in the parameter list as specified in the writeFmt string. You should not use the viWrite and viPrintf functions in the same session.

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.

writeFmt

IN

string

String describing the format for arguments.

overloaded argument

IN

N/A

A parameter the format string is applied to.

Return Values 

Completion Code

Description

VI_SUCCESS

Parameters were successfully formatted.

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 writeFmt 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 write function because of I/O error.

VI_ERROR_NSUP_FMT

A format specifier in the writeFmt 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 write function completed.

 

  C# Example

// Writes a comma-separated list of NR1-style integers to the formatted I/O // buffer and flushes the buffer (because of the "\n".) public void WriteCommaSeparatedInt32List(int session, int[] data, int count) { string format = "%dl," + count + "\n"; int viError; viError = visa32.viPrintf(session, format, 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()); } }

VB .NET Example

' Writes a comma-separated list of NR1-style integers to the formatted I/O ' buffer and flushes the buffer (because of the "\n".) Public Sub WriteCommaSeparatedInt32List(ByVal session As Integer, _ ByVal data() As Integer, _ ByVal count As Integer)    Dim format As String = "%," & count & "d" & vbLf    Dim viError As Integer    viError = visa32.viPrintf(session, format, 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 End Sub