10    ! GETASCII
20    !-------------------------------------------------------------------------
30    ! HPBASIC/IBASIC Program: ASCII query
40    ! This program will read back the trace data values (401 data points for
50    ! default FFT analysis) and display the first ten values on the screen.
60    ! This program will also distinguish between HPBASIC and IBASIC run modes
70    !-------------------------------------------------------------------------
80    !
90    ON ERROR GOTO Not_ibasic     ! auto selection of proper select code
100   Device=800                   ! device select code from IBASIC
110   CLEAR Device
120   GOTO Start_prog
130   !
140 Not_ibasic: !
150   Device=711                   ! device select code from external computer
160 Start_prog: !
170   OFF ERROR
180   !
190   !
200   ASSIGN @Analyzer TO Device   ! allows code to be address independent
210   !
220   DIM A(400)                              ! 401 values to be read
230   OUTPUT @Analyzer;"*RST"                 ! Reset the analyzer
240   OUTPUT @Analyzer;"ABORT;:INIT; *WAI"    ! start measurements
250   OUTPUT @Analyzer;":INIT:CONT OFF"       ! pause after first measurement
260   !
270   ! select the ASCII data format.  block data will be output from the
280   ! analyzer with numbers formatted in ASCII character strings.
290   OUTPUT @Analyzer;"FORM:DATA ASCII"
300   !
310   ! command the analyzer to output the data from trace A
320   OUTPUT @Analyzer;"CALC1:DATA?"
330   !
340   ! open up a display window if in IBASIC running in the analyzer
350   IF Device=800 THEN OUTPUT @Analyzer;"DISP:PROG LOW"
360   !
370   ! read the data from the analyzer
380   FOR I=0 TO 400
390     !
400     ! read in 1 point of data. '%' in USING image causes BASIC to
410     ! just read the number and don't search for <cr><lf>.
420     ENTER @Analyzer USING "%,K";A(I)
430     IF I<10 THEN PRINT "Data point ";I,A(I)
440   NEXT I
450   !
460   END
