Programming Examples
40
Keysight InfiniiVision M9241/42/43A PXIe Oscilloscopes SCPI Programmer's Guide
1429
err = viFlush(vi, VI_READ_BUF)
If (err <> VI_SUCCESS) Then HandleVISAError vi
err = viFlush(vi, VI_WRITE_BUF)
If (err <> VI_SUCCESS) Then HandleVISAError vi
' retCount is now actual number of bytes returned by query.
DoQueryIEEEBlock_Bytes = retCount
CheckInstrumentErrors
End Function
Private Sub CheckInstrumentErrors()
On Error GoTo ErrorHandler
Dim strErrVal As String * 200
Dim strOut As String
err = viVPrintf(vi, ":SYSTem:ERRor?" + vbLf, 0)
' Query any errors.
If (err <> VI_SUCCESS) Then HandleVISAError vi
err = viVScanf(vi, "%t", strErrVal)
' Read: Errnum,"Error String".
If (err <> VI_SUCCESS) Then HandleVISAError vi
While Val(strErrVal) <> 0
' End if find: 0,"No Error".
strOut = "INST Error: " + strErrVal
err = viVPrintf(vi, ":SYSTem:ERRor?" + vbLf, 0)
' Request error.
If (err <> VI_SUCCESS) Then HandleVISAError vi
err = viVScanf(vi, "%t", strErrVal)
' Read error message.
If (err <> VI_SUCCESS) Then HandleVISAError vi
Wend
If Not strOut = "" Then
MsgBox strOut, vbExclamation, "INST Error Messages"
err = viFlush(vi, VI_READ_BUF)
If (err <> VI_SUCCESS) Then HandleVISAError vi
err = viFlush(vi, VI_WRITE_BUF)
If (err <> VI_SUCCESS) Then HandleVISAError vi
End If
Exit Sub
ErrorHandler:
MsgBox "*** Error : " + Error, vbExclamation
End
End Sub