Operating instructions

R&S ESCI More Complex Programming Examples
1166.6004.12 7.45 E-1
Reading and Writing Files
Reading a File from the Instrument
In the following example, file TEST1.SET stored under D:\USER\DATA is read from the instrument and
stored in the controller.
REM ************************************************************************
Public Sub ReadFile()
'--------- Generate variables ----------------------------------------------
Dim digits As Byte 'Number of digits of
'length information
Dim fileBytes As Long 'Length of file with trace data
'in bytes
result$ = Space$(100) 'Buffer for simple results
'--------- Default setting of status register ------------------------------
Call SetupStatusReg 'Configure status register
'--------- Read out file ---------------------------------------------------
Call ibwrt(receiver%, "MMEM:DATA? 'D:\USER\DATA\TEST1.SET'")
'Select file
Call ilrd(receiver%, result$, 2) 'Read and store number of
digits = Val(Mid$(result$, 2, 1)) 'digits of length information
Call ilrd(receiver%, result$, digits) 'Read and store length
fileBytes = Val(Left$(result$, digits)) 'information
FileBuffer$ = Space$(fileBytes) 'Buffer for file
Call ilrd(receiver%, FileBuffer, fileBytes) 'Read file into buffer
Call ilrd(receiver%, result$, 1) 'Read terminator <NL>
'--------- Store file to controller ---------------------------------------
Open "TEST1.SET" For Output As #1
Print #1, FileBuffer; ' ; to avoid linefeed at
' end of file
Close #1
END SUB
REM
************************************************************************