Manual

Appendix G 17-1
17 Appendix G Example Program
Here is a simple BASIC program for controlling the Automove System from a
Hewlett-Packard Series 200 computer. This program asks the user to enter 5 points with the
TEACH button; then it "plays back" the 5 points.
In this version of the BASIC language, the "!" character indicates that the remainder of the
current line is a comment. Variable names can have many characters; this program uses
variables with the names Rs232, Ans$, Esc$, X, Y, Comma, and Dummy.
The OUTPUT statement is similar to PRINT, but sends its output to a specified port.
ENTER is similar to INPUT, but gets its input from a port instead of the keyboard. The
notation Ans$[m,n] means the m'th through n'th characters of the string named "Ans$", and
Ans$[m] means the m'th through last characters of the string.
10 ! Automove example program. Assumes
20 ! that the Hardwired DTR handshake is
30 ! automatically executed by the RS-232C
40 ! interface hardware.
50 !-------------------------------------------
60 DIM Ans$[30] ! string for "answers"
70 DIM X(5),Y(5) ! storage for taught points
80 Rs232=9 ! RS232C port select code
90 Esc$=CHR$(27) ! the "Escape" character
100 OUTPUT Rs232;"IN;"; ! initialize Automove
110 OUTPUT Rs232;"FH;"; ! find Home switches
120 !-------------------------------------------
130 ! Now have the operator "teach" 5 points:
140 !-------------------------------------------
150 PRINT "Please enter 5 points with TEACH."
160 FOR I=1 TO 5
170 OUTPUT Rs232;"OT;"; ! request taught point
180 ! The following line hangs until the
190 ! user presses the TEACH button:
200 ENTER Rs232;Ans$ ! read the point
210 ! Check for "exceptional conditions":
220 IF Ans$[1;1]="?" THEN 540
230 Comma=POS(Ans$,",") ! where's the comma?
240 X(I)=VAL(Ans$[1,Comma-1]) ! X value
250 Y(I)=VAL(Ans$[Comma+1]) ! Y value
260 BEEP ! give the user audible feedback
(Example program, cont'd.)