53
Appendix B
Sample Programs
B.1 Example Program for RS-232C Communication (GWBASIC)
10 ‘****************************Program Header **************************
20 ‘Newport Corporation
30 ‘1830-C to RS-232 Communication Program - an example program
40 ‘
50 ‘This program is designed to show you how to write a simple
60 ‘program that will write commands and read query responses to and
70 ‘from the 1830-C via the RS-232 port on the 1830-C Rear panel and the
80 ‘RS-232 port on an IBM PC/AT or compatible. The program was written in
90 ‘MICROSOFT GWBASIC on an IBM AT compatible.
100 ‘
110 ‘Note that if the 1830-C is reset while the program is running the
120 ‘program must be restarted so that the ECHO mode will be disabled.
130 ‘
140 ‘Written By : Rakesh Pandit
150 ‘ Date: June 24th,1994
160 ‘************************** End of Header ****************************
170 ‘
1000 ‘Beginning of program
1010 ‘Open COM port with the following specifications:
1020 ‘COM port 1, 9600 baudrate, no parity, 8 data bits & 1 stop bit
1030 OPEN “COM1:9600,N,8,1” FOR RANDOM AS #1
1040 GOSUB 2000 ‘ Display Newport Greeting
1050 GOSUB 6000 ‘ 1830-C’s echo mode disabled
1060 GOSUB 3000 ‘ Process user input
1070 CLOSE #1 ‘ Close the COM file
1080 END ‘End of program
1090 ‘
2000 ‘Main Screen : Draw the main screen
2010 CLS
2020 LOCATE 1, 24: PRINT “NEWPORT CORPORATION “
2030 LOCATE 2, 20: PRINT “1830-C TO IBMPC RS-232C Communication Program”
2040 PRINT : PRINT
2050 RETURN