Specifications
194 Chapter 16 
ESA/PSA Programming Examples
Using Visual Basic® 6 to Transfer Binary Trace Data
ESA/PSA Programming Examples
 Dim ResultsArray(8192) As Single ’trace element array of Real,32 values
 ’For Real,64 data use Double. For Int,32 data use Long
 Dim length As Long ’Number of trace elements return from instrument
 Dim fnum As Integer ’File Number to used to open file to store data
 Dim isOpen As Boolean ’Boolean flag used to keep track of open file
 ’Set the default number of trace elements to the ResultsArray size
 ’Note: PSA and ESA currently support up to 8192 trace points
 length = 8192
 ’Set the array of pointers to the addresses of the variables
 ArrayPtr(0) = VarPtr(length)
 ArrayPtr(1) = VarPtr(ResultsArray(0))
 On Error GoTo Error_Handler
 ’ Open the default resource manager session
 status = viOpenDefaultRM(defrm)
 ’ Open the session. Note: For PSA, to use LAN, change the string to
 ’ "TCPIP0::xxx.xxx.xxx.xxx::inst0::INTSR" where xxxxx is the IP address
 status = viOpen(defrm, "GPIB0::18::INSTR", 0, 0, vi)
 If (status < 0) Then GoTo VisaErrorHandler
 ’ Set the I/O timeout to five seconds
 status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 5000)
 If (status < 0) Then GoTo VisaErrorHandler
 ’Ask for the devices’s *IDN string.
 status = viVPrintf(vi, "*IDN?" + Chr$(10), 0)
 If (status < 0) Then GoTo VisaErrorHandler
 ’Read back the IDN string from the instrument
 status = viVScanf(vi, "%t", strRes)
 If (status < 0) Then GoTo VisaErrorHandler










