Other topics about Sample Programs
This sample program demonstrates how to use an SRQ to detect the occurrence of an error.
This program sets SRQs and then intentionally sends an invalid parameter to generate an error to be handled by this program. In the error handling part, this program examines the error, displays the error number and error message, and then displays the message indicating the suspension of the program. See Detecting Occurrence of an Error for this programming.
The sequence interception by an error can not be performed on Excel VBA.
10 DIM Buff$[9],Err_mes$[50]
20 INTEGER Err_no
30 !
40 ASSIGN @Agte507x TO 717
50 !
60 OUTPUT @Agte507x;"*ESE 60"
70 OUTPUT @Agte507x;"*SRE 32"
80 OUTPUT @Agte507x;"*CLS"
90 OUTPUT @Agte507x;"*OPC?"
100 ENTER @Agte507x;Buff$
110 !
120 ON INTR 7 GOTO Err_proc
130 ENABLE INTR 7;2
140 OUTPUT @Agte507x;":CALC1:PAR:COUN 2"
150 PRINT "Trace 1 Meas.Para: S21"
160 PRINT "Trace 1 Format : Log Mag"
170 OUTPUT @Agte507x;":CALC1:PAR1:DEF S21"
180 OUTPUT @Agte507x;":CALC1:PAR1:SEL"
190 OUTPUT @Agte507x;":CALC1:FORM MLOG"
200 PRINT "Trace 2 Meas.Para: S11"
210 PRINT "Trace 2 Format : Log Mag"
220 OUTPUT @Agte507x;":CALC1:PAR2:DEF S11"
230 OUTPUT @Agte507x;":CALC1:PAR2:SEL"
240 OUTPUT @Agte507x;":CALC1:FORM LOG"
250 OUTPUT @Agte507x;"*OPC?"
260 ENTER @Agte507x;Buff$
270 GOTO Skip_err_proc
280 Err_proc: OFF INTR 7
290 OUTPUT @Agte507x;";:SYST:ERR?"
300 ENTER @Agte507x;Err_no,Err_mes$
310 PRINT "Error occurred!!"
320 PRINT " No:";Err_no,"Description: "&Err_mes$
330 PRINT "PROGRAM INTERRUPT!!"
340 GOTO Prog_end
350 Skip_err_proc: PRINT "PROGRAM DONE."
360 Prog_end: END
Line 40
Assigns a GPIB address to the I/O pass.
Lines 60 to 70
These lines enable bits 2, 3, 4 and 5 in the standard event status register and set bit 5 to 1 in the service request enable register.
Lines 80 to 100
These lines clear the status byte register, the standard event status register, and the error queue.
Lines 120 to 130
These lines set the branch target for an SRQ interrupt to enable SRQ interruptions.
Lines 140 to 260
These lines set the measurement parameters and their data formats for traces 1 and 2. An invalid parameter is given to the data format setting for trace 2, causing an error.
Lines 280 to 330
These lines define an error handler in the following way.
Lines 290 to 300: These lines retrieve the error number and error messages for the error from the error queue.
Lines 310 to 330 These lines display the message indicating the occurrence of the error, the error number, the error message, and the message showing that the program is suspended.
Line 350
Displays a closing message. Note that this message will not display unless this program is re-executed after setting a corrected parameter to the data format setting for trace 2.