Other topics about Sample Programs
This sample program demonstrates hw to transfer files between the external controller and the E5063A.
This program reads out data from a specified file on the external controller (or the E5063A), then writes them to a specified file on the E5063A (or the external controller).
See Managing Files for this programming.
Example of excel sheet and window form with transferring files program
Private Sub fromENA_toPC_Click()
'*** This sequence is a sample code in which the file is transferred
'*** from the ENA to the external controller.
Dim hFile As Long
Dim isOpen As Boolean
Dim ioMgr As VisaComLib.ResourceManager
Set ioMgr = New VisaComLib.ResourceManager
Dim Ena As VisaComLib.FormattedIO488
Set Ena = New VisaComLib.FormattedIO488
Set Ena.IO = ioMgr.Open("GPIB0::17::INSTR")
Ena.IO.Timeout = 10000
Dim byteData() As Byte
Dim Ena_File As String
Dim PC_File As String
Ena_File = """" & Trim(TextBox2.Text) & """"
PC_File = Trim(TextBox1.Text)
Ena.WriteString ":MMEM:TRAN? " & Ena_File
byteData = Ena.ReadIEEEBlock(BinaryType_UI1)
hFile = FreeFile()
Open PC_File For Binary Access Write Shared As hFile
isOpen = True
Put #hFile, , byteData
If isOpen Then Close #hFile
Ena.IO.Close
End Sub
Private Sub fromPC_toENA_Click()
'*** This sequence is a sample code in which the file is transferred
'*** from the external controller to the ENA.
Dim hFile As Long
Dim isOpen As Boolean
Dim ioMgr As VisaComLib.ResourceManager
Set ioMgr = New VisaComLib.ResourceManager
Dim Ena As VisaComLib.FormattedIO488
Set Ena = New VisaComLib.FormattedIO488
Set Ena.IO = ioMgr.Open("GPIB0::17::INSTR")
Ena.IO.Timeout = 10000
Dim byteData() As Byte
Dim strBuf As String
Dim fileSize As Long
Dim Ena_File As String
Dim PC_File As String
Ena_File = """" & Trim(TextBox2.Text) & """"
PC_File = Trim(TextBox1.Text)
fileSize = FileLen(PC_File)
ReDim byteData(fileSize - 1)
hFile = FreeFile()
Open PC_File For Binary Access Read Shared As hFile
isOpen = True
Get #hFile, , byteData
If isOpen Then Close #hFile
strBuf = ":MMEM:TRAN " & Ena_File & ","
Ena.WriteIEEEBlock strBuf, byteData, True
Ena.IO.Close
End Sub