User manual

RIGOL Chapter 3 Programming Examples
3-12 RSA3000 Programming Guide
Dim rSize As Long
'Initialize the system
status = viOpenDefaultRM(dfltRM)
'Failed to initialize the system
If (status < VI_SUCCESS) Then
MsgBox " No VISA resource was opened"
Exit Sub
End If
'Open the VISA instrument
status = viOpen(dfltRM, rsrcName, VI_NULL, VI_NULL, sesn)
'Failed to open the instrument
If (status < VI_SUCCESS) Then
MsgBox "Failed to open the instrument"
Exit Sub
End If
'Write command to the instrument
status = viWrite(sesn, strCmd, Len(strCmd), rSize)
'Failed to write to the instrument
If (status < VI_SUCCESS) Then
MsgBox " Faild to write to the instrument"
Exit Sub
End If
'Close the system
status = viClose(sesn)
status = viClose(dfltRM)
End Sub
2) Encapsulate the read operation of VISA for easier operation.
'-----------------------------------------------------------
'Function NameInstrRead
'FunctionRead the return value from the instrument
'InputrsrcName,Resource name
'ReturnThe string gotten from the instrument
'-----------------------------------------------------------
Public Function InstrRead(rsrcName As String) As String
Dim status As Long
Dim dfltRM As Long
Dim sesn As Long
Dim strTemp0 As String * 256
Dim strTemp1 As String
Dim rSize As Long
'Begin by initializing the system
status = viOpenDefaultRM(dfltRM)
'Initialization failed
If (status < VI_SUCCESS) Then
MsgBox " Failed to open the instrument! "
Exit Function
End If
'Open the instrument
status = viOpen(dfltRM, rsrcName, VI_NULL, VI_NULL, sesn)
'Failed to open the instrument
If (status < VI_SUCCESS) Then