Appendix H
Sample Programs
© National Instruments Corp.
H-7
GPIB-232CT User Manual
Step 4. Communicate with
rd
and
wrt
Functions
Communicate with the device using
wrt
programming messages, and
reading back status after each. Here is the heart of the program. After each
wrt
string, call the subroutine
status
, which will check for errors. The
plotter's GPIB address is 5.
OPEN "com1:9600,n,7,1" AS #1
PRINT #1,"stat c n"
GOSUB
status
PRINT #1,"wrt 5"
PRINT #1,"in;sp1,pa1000,3000;ci500;"
GOSUB
status
END
status:
STAT%=VAL(LINE INPUT #1, status$)
LINE INPUT #1,gpiberr$
LINE INPUT #1,sperr$
LINE INPUT #1,cnt$
PRINT status$ gpiberr$ sperr$ cnt$
if stat% < 0 GOSUB error
error:
REM Place your code to handle errors here.
STOP