	PROGRAM RTSET
C
C	18-FEB-83
C
C	BOB FRAZER, 7523, SNLA, 844-7863
C
C
C	PROGRAM SETS UP (CUSTOMIZES) RTCOM FOR A USER, BY A USER
C
C
	INTEGER RCSR,RVEC,LCSR,LVEC,OPTN,HNGTIM,NOSDEL,HSTEF1,HSTEF2
	INTEGER IOPT(6),VAXNOS,DISPLY,BINARY,SETUP,ONOFF,CRLF
	INTEGER IDAT(256),TABLE(16)
	INTEGER*2	ASC(256)
	BYTE FILNAM(40)
C
	EQUIVALENCE (RCSR,   IDAT(1)),(RVEC,   IDAT(2)),
     1           (LCSR,   IDAT(3)),(LVEC,   IDAT(4)),
     2           (OPTN,   IDAT(5)),(HNGTIM, IDAT(6)),
     3           (NOSDEL, IDAT(7)),(HSTEF1, IDAT(8)),
     4           (HSTEF2, IDAT(9))
	EQUIVALENCE (TABLE(1),IDAT(10))
	EQUIVALENCE (VAXNOS, IOPT(1)),(DISPLY, IOPT(2)),
     1            (BINARY, IOPT(3)),(SETUP,  IOPT(4)),
     2            (ONOFF,  IOPT(5)),(CRLF,   IOPT(6))
C
	DATA	ASC /
     1		     'nu','so','st','^c','eo','en','ac','bl',
     1		     'bs','ht','lf','vt','ff','cr','^n','^o',
     2		     'dl','^q','^r','^s','^t','nk','^v','^w',
     2		     '^x','^y','^z','es','^\','^]','^^','^_',
     3		     '  ',' !',' "',' #',' $',' %',' &',' ''',
     3		     ' (',' )',' *',' +',' ,',' -',' .',' /',
     4		     ' 0',' 1',' 2',' 3',' 4',' 5',' 6',' 7',
     4		     ' 8',' 9',' :',' ;',' <',' =',' >',' ?',
     5		     ' @',' A',' B',' C',' D',' E',' F',' G',
     5		     ' H',' I',' J',' K',' L',' M',' N',' O',
     6		     ' P',' Q',' R',' S',' T',' U',' V',' W',
     6		     ' X',' Y',' Z',' [',' \',' ]',' ^',' _',
     7		     ' `',' a',' b',' c',' d',' e',' f',' g',
     7		     ' h',' i',' j',' k',' l',' m',' n',' o',
     8		     ' p',' q',' r',' s',' t',' u',' v',' w',
     8		     ' x',' y',' z',' {',' |',' }',' ~','xx',
     1		     'NU','SO','ST','>C','EO','EN','AC','BL',
     1		     'BS','HT','LF','VT','FF','CR','>N','>O',
     2		     'DL','>Q','>R','>S','>T','NK','>V','>W',
     2		     '>X','>Y','>Z','ES','>\','>]','>^','>_',
     3		     '* ','*!','*"','*#','*$','*%','*&','*''',
     3		     '*(','*)','**','*+','*,','*-','*.','*/',
     4		     '*0','*1','*2','*3','*4','*5','*6','*7',
     4		     '*8','*9','*:','*;','*<','*=','*>','*?',
     5		     '*@','*A','*B','*C','*D','*E','*F','*G',
     5		     '*H','*I','*J','*K','*L','*M','*N','*O',
     6		     '*P','*Q','*R','*S','*T','*U','*V','*W',
     6		     '*X','*Y','*Z','*[','*\','*]','*^','*_',
     7		     '*`','*a','*b','*c','*d','*e','*f','*g',
     7		     '*h','*i','*j','*k','*l','*m','*n','*o',
     8		     '*p','*q','*r','*s','*t','*u','*v','*w',
     8		     '*x','*y','*z','*{','*|','*}','*~','XX'/
C
	DATA IOPT/"100000,"020000,"010000,"001000,"000100,"000001/
C
100	FORMAT (1X,'  1. HOST    RCSR, VECTOR           =   ',O6,1X,O3)
102	FORMAT (1X,'  2. PRINTER RCSR, VECTOR           =   ',O6,1X,O3)
105	FORMAT (1X,'  3.     HOST TYPE                  =   ',2X,A4)
106	FORMAT (1X,'  4.     DISPLAY     QUESTION       ?   ',2X,A4)
107	FORMAT (1X,'  5.     BINARY FILE QUESTION       ?   ',2X,A4)
108	FORMAT (1X,'  6.     INITIAL SETUP MESSAGE      ?   ',2X,A4)
109	FORMAT (1X,'  7.     PRINTER                        ',2X,A4)
110	FORMAT (1X,'  8.     CRLF TO HOST               ?   ',2X,A4)
111	FORMAT (1X,'  9. HOST TIME-OUT IN MILLISECONDS      ',I6)
112	FORMAT (1X,' 10. NOS MILLISECOND DELAYS AFTER CR    ',I6)
113	FORMAT (1X,' 11. HOST TWO CHAR EOF SEQUENCE (OCTAL) ',3X,O3,1X,O3,
     1       2(1X,A2))
114	FORMAT (2X,I2,'. TABLE  RCSR, VECTOR          ',6X,O6,1X,O3,2A4)
115	FORMAT (1X,' RTCOM FILE NAME (XXXXXX.SAV) ? ',$)
116	FORMAT (40A1)
117	FORMAT (20X,2A4,/)
118	FORMAT (1X,/,' CHANGE NUMBER (0=NONE) ? ',$)
119	FORMAT (I2)
120	FORMAT (1X,' SAVE THE CHANGES ? ',$)
121	FORMAT (A1)
122	FORMAT (1X,' NEW  CSR, VECTOR (OCTAL) (1xxxx0,3x0) ? ',$)
123	FORMAT (O6,1X,O3)
124	FORMAT (1X,' NEW TIME (MILLISECONDS) ? ',$)
125	FORMAT (I6)
126	FORMAT (1X,' CANNOT CHANGE CONSOLE !!')
127	FORMAT (1X,' SET NUMBER FROM TABLE (<CR>=0, NO DEVICE) ')
128	FORMAT (1X,' HOST CSR, OR VECTOR, CANNOT BE ZERO ')
129	FORMAT (1X,' got to be in OCTAL !!!',/
     1        1X,' 160000 <=  RCSR  <= 177670  and end in 0',/
     2        1X,'    300 <= VECTOR <=    370  and end in 0')
130	FORMAT (1X,' DONE ? <CR>= NO ? ',$)
131	FORMAT (1X,' NOT IN TABLE ')
132	FORMAT (1X,' ENTER TWO OCTAL EQUIVALENTS OF EOF CHAR.S - ',$)
133	FORMAT (10A1)
134	FORMAT (1X,' GOT TO BE OCTAL !!!, OOO,OOO  <= 377 ')
135	FORMAT (1X,' HOST AND PRINTER CANNOT BE THE SAME DEVICE !!!!')
C
5	DO 10 I=1,40
		FILNAM(I)=' '
10	CONTINUE
	WRITE (7,115)
	READ  (5,116) FILNAM
	OPEN (UNIT=11,
     2     NAME=FILNAM,
     3     TYPE='OLD',
     4     ACCESS='DIRECT',
     5     MAXREC=0,
     6     RECORDSIZE=128,
     7     ERR=5)
	JREC=2
	READ (11'JREC) IDAT
	ICH=0
	ANS1='ORIG'
	ANS2='INAL'
20	WRITE (7,117) ANS1,ANS2
	WRITE (7,100) RCSR,RVEC
	WRITE (7,102) LCSR,LVEC
	ANS1=' NOS'
	IF ((OPTN.AND.VAXNOS).EQ.0) ANS1=' VAX'
	WRITE (7,105) ANS1
	ANS1=' YES'
	IF ((OPTN.AND.DISPLY).NE.0) ANS1='  NO'
	WRITE (7,106) ANS1
	ANS1=' YES'
	IF ((OPTN.AND.BINARY).NE.0) ANS1='  NO'
	WRITE (7,107) ANS1
	ANS1=' YES'
	IF ((OPTN.AND.SETUP ).NE.0) ANS1='  NO'
	WRITE (7,108) ANS1
	ANS1='  ON'
	IF ((OPTN.AND.ONOFF ).EQ.0) ANS1=' OFF'
	WRITE (7,109) ANS1
	ANS1=' YES'
	IF ((OPTN.AND.CRLF  ).EQ.0) ANS1='  NO'
	WRITE (7,110) ANS1
	WRITE (7,111) HNGTIM
	WRITE (7,112) NOSDEL
	J=ASC(HSTEF1+1)
	K=ASC(HSTEF2+1)
	WRITE (7,113) HSTEF1,HSTEF2,J,K
	L=11
	DO 200 I=1,15,2
		ANS1='    '
		ANS2='    '
		L=L+1
		J=TABLE(I)
		K=TABLE(I+1)
		IF (J.EQ.0) GO TO 190
		IF (J.NE."177560) GO TO 170
		ANS1=' CON'
		ANS2='SOLE'
		GO TO 190
170		IF (J.NE.RCSR) GO TO 180
		ANS2='HOST'
		GO TO 190
180		IF (J.NE.LCSR) GO TO 190
		ANS1=' PRI'
		ANS2='NTER'
190		WRITE (7,114) L,J,K,ANS1,ANS2
200	CONTINUE
201	WRITE (7,118)
	J=0
	K=0
	L=0
	ICSR=0
	IVEC=0
	READ  (5,119) L
	IF (L.EQ.0) GO TO 300
	IF (L.GT.19) GO TO 201
	ANS1='CHAN'
	ANS2='GED '
	ICH=ICH+1
	IF (L.GT.11) GO TO 202
	GO TO (21,22,23,24,25,26,27,28,29,30,31) L
C
202	IF (L.EQ.12) GO TO 206
	J=((L-12)*2)+1			! TABLE ENTRIES
	K=J+1
	WRITE (7,122)
	READ  (5,123,ERR=205) ICSR,IVEC
	IF ((ICSR.AND."000007).NE.0) GO TO 205
	IF ((IVEC.AND."000007).NE.0) GO TO 205
	IF (ICSR.LT."160000) GO TO 205
	IF (ICSR.GT."177670) GO TO 205
	IF (IVEC.LT."300   ) GO TO 205
	IF (IVEC.GT."370   ) GO TO 205
	TABLE(J)=ICSR
	TABLE(K)=IVEC
	GO TO 20
204	WRITE (7,128)
	GO TO 201
205	WRITE (7,129)
	GO TO 201
206	WRITE (7,126)
	GO TO 201
207	WRITE (7,131)
	GO TO 201
208	WRITE (7,135)
	GO TO 201
C
21	CONTINUE			! HOST RCSR, VECTOR
	WRITE (7,127)
	READ  (5,119) ICSR
	IF (ICSR.NE.0) GO TO 211
	IF (L.EQ.1) GO TO 204
	LCSR=0
	LVEC=0
	J=.NOT.ONOFF
	OPTN=OPTN.AND.J
	GO TO 20
211	IF (ICSR.LT.13) GO TO 207
	IF (ICSR.GT.19) GO TO 207
	ICSR=((ICSR-12)*2)+1
	IVEC=ICSR+1
	IF (L.EQ.2) GO TO 221
	J=TABLE(ICSR)
	K=TABLE(IVEC)
	IF (J.EQ.LCSR) GO TO 208
	RCSR=J
	RVEC=K
	GO TO 20
C
22	CONTINUE			! PRINTER RCSR, VECTOR
	GO TO 21
221	J=TABLE(ICSR)
	K=TABLE(IVEC)
	IF (J.EQ.RCSR) GO TO 208
	LCSR=J
	LVEC=K
	GO TO 20
C
23	CONTINUE		! HOST TYPE, VAX OR NOS
24	CONTINUE		! DISPLAYS
25	CONTINUE		! BINARY FILES
26	CONTINUE		! INITIAL SETUP MESSAGE
27	CONTINUE		! PRINTER ON/OFF
28	CONTINUE		! CRLF TO HOST
	J=L-2
	K=IOPT(J)
	OPTN=OPTN.XOR.K
	GO TO 20
C
29	CONTINUE		! HOST HANG TIME, MILLISECONDS
	WRITE (7,124)
	READ  (5,125) HNGTIM
	GO TO 20
C
30	CONTINUE		! NOS CR DELAY, MILLISECONDS
	WRITE (7,124)
	READ  (5,125) NOSDEL
	GO TO 20
C
31	CONTINUE		! TWO CHAR HOST EOF SEQUENCE
	WRITE (7,132)
	DO 311 J=1,10
		FILNAM(J)=' '
311	CONTINUE
	READ  (5,133) (FILNAM(I),I=1,10)
	I=0
	J=0
	K=0
	L=0
312	I=I+1
	J=FILNAM(I)-'0'
	IF (J.LT.0) GO TO 315
	IF (J.GT.7) GO TO 319
	K=(K*8)+J
	GO TO 312
315	I=I+1
	J=FILNAM(I)-'0'
	IF (J.LT.0) GO TO 317
	IF (J.GT.7) GO TO 319
	L=(L*8)+J
	GO TO 315
317	IF (K.GT.255) GO TO 319
	IF (L.GT.255) GO TO 319
	HSTEF1=K
	HSTEF2=L
	GO TO 20
319	WRITE (7,134)
	GO TO 20
C
300	FILNAM(40)=' '
	WRITE (7,130)
	READ  (5,121) FILNAM(40)
	ANS1=' CHA'
	ANS2='NGED'
	IF (FILNAM(40).NE.'Y') GO TO 20
	IF (ICH.EQ.0) GO TO 999
	WRITE (7,120)
	FILNAM(40)=' '
	READ  (5,121) FILNAM(40)
	IF (FILNAM(40).NE.'Y') GO TO 999
	WRITE (11'JREC) IDAT
999	CLOSE (UNIT=11)
	STOP
	END
