Other topics about Sample Programs
The sample program demonstrates to Write Formatted Data Arrays in Using the Binary Transfer Format
See Entering Data into a Trace for this programming.
10 REAL Freq,Fdata(1:1601,1:2)
20 DIM File$[300],Header$[10]
30 INTEGER Nop
40 !
50 ASSIGN @Agte507x TO 717
60 ASSIGN @Binary TO 717;FORMAT OFF
70 CALL Inp_file_name(File$)
80 !
90 OUTPUT @Agte507x;":CALC1:PAR1:SEL"
100 OUTPUT @Agte507x;":INIT1:CONT OFF"
110 OUTPUT @Agte507x;":ABOR"
120 !
130 OUTPUT @Agte507x;":SENS1:SWE:POIN?"
140 ENTER @Agte507x;Nop
150 REDIM Fdata(1:Nop,1:2)
160 !
170 ON ERROR GOTO File_error
180 ASSIGN @File TO File$
190 ENTER @File USING "K";Buff$
200 ENTER @File USING "K";Buff$
210 ENTER @File USING "K";Buff$
220 FOR I=1 TO Nop
230 ENTER @File USING "19D,2X,19D,2X,19D";Freq,Fdata(I,1),Fdata (I,2)
240 NEXT I
250 ASSIGN @File TO *
260 OFF ERROR
270 !
280 OUTPUT @Agte507x;":FORM:DATA REAL"
290 Header$="#6"&IVAL$(8*2*Nop,10)
300 OUTPUT @Agte507x;":CALC1:DATA:FDAT ";Header$;
310 OUTPUT @Binary;Fdata(*),END
320 GOTO Prog_end
330 !
340 File_error: OFF ERROR
350 PRINT "############ ERROR ############"
360 PRINT File$&" is NOT exist."
370 PRINT " or"
380 PRINT File$&" has UNSUITABLE data."
390 !
400 Prog_end: END
410 !=============================================
420 ! File Name Input Function
430 !=============================================
440 SUB Inp_file_name(Inp_name$)
450 DIM Inp_char$[9]
460 ON ERROR GOTO Inp_start
470 Inp_start: !
480 PRINT "Input File Name!"
490 INPUT "Name?",Inp_name$
500 PRINT "Input Name: "&Inp_name$
510 INPUT "OK? [Y/N]",Inp_char$
520 IF UPC$(Inp_char$)<>"Y" THEN Inp_start
530 OFF ERROR
540 SUBEND
Lines 50 to 60
Assigns a GPIB address to the I/O pass.
Line 70
Passes control to a subprogram named Inp_file_name, which lets the user input a file name, and then stores the returned file name into the File$ variable.
Lines 90 to 110
These lines set channel 1's active trace to trace 1 and hold the sweep.
Lines 130 to 140
These lines retrieve the number of points in channel 1 and stores that number into the Nop variable.
Line 150
Resizes the Fdata array based on the value of the Nop variable (the number of points).
Line 170
This line points to the statement block to be executed if an error occurs in retrieving data from the file (for example, if no file matches File$).
Lines 180 to 260
These lines retrieve the formatted data from the file identified by File$, and store the data into the Fdata array.
Line 280
Sets the data transfer format to binary.
Line 290
Creates the data header and stores it into the Header$ variable.
Line 300
Sends the command that writes data into the formatted data array for the active trace (trace 1) in channel 1, following it with the data header (Header$).
Line 310
Sends the data itself (Fdata), following it with a message terminator.
Because binary data must be written without being formatted, the program uses an I/O path (@Binary) that is configured to support writing unformatted data.
Lines 340 to 380
This statement block is executed if an error occurs in retrieving data from the file.
The Inp_file_name subprogram in lines 440 to 540, which is used to enter a save filename, is described below.
Line 460
Allows the user to return to the entry start line and re-enter the data if an error (such as an invalid entry) occurs while entering the target file name.
Lines 480 to 490
These lines prompt the user to enter the target file name. The program does not continue till the user actually enters the file name.
Lines 500 to 510
These lines display the entered file name and waits for a confirmation entry (y/n key).
Line 520
Returns to the entry start line if the key the user pressed in line 870 is not the y key.