	PROGRAM RADIXINIT
C   Jim Walker, 21 Nov 1987 for NBS.
C   This program sets the current angle for a diffractometer.
C
	INCLUDE '[102,2]INP.COM'
	INCLUDE '[102,2]IOBLK.COM'
	INCLUDE '[102,2]ERRBLK.COM'
	INCLUDE '[102,2]XRYDES.COM' ! specific information from XRAY.XRY
C
	CHARACTER COMAND*60,DIFVER*1
	INTEGER*2 IFLAG, IREC,DIFNUM
C
	CALL LIB$GET_FOREIGN(COMAND)
C
	IF(COMAND.EQ.'NB4 000 ') GOTO 9999
	IF(COMAND(1:6).EQ.'NB3 20') GOTO 9999
C
	TYPE 4,27,27
4	FORMAT(X,A1,'[H',A1,'[2J',////,10X,
	1  'RADIX INTERFACE ANGLE INITIALIZATION PROGRAM',//,
	2  20X,'Enter a blank line to EXIT',/)
D	TYPE*,COMAND
C
C++++ siemens code
	IUNIT  = 1 ! misc unit
	IXRY   = 4 ! unit for XRAY.XRY
	IXRD   = 1 ! unit for XRYnnL.XRY
C
	PROG   ='RINIT'   !JDW03                !set the program name 
	IERR(5)= 0                         ! setup error flag
C
	ERRLOG='TI:'
	ERRLOG(4:4)=CHAR(0)
	CALL OPSYS(IUNIT)                  ! read FILLOC.FIL
	IF(IERR(5).NE.0) THEN              ! error reading info from FILLOC.FIL
		CALL ERRMSG('OPSYS ',XRYFIL,1,COMAND)
		GOTO 99999
	ENDIF
C       now I need the corresponding terminal#
C
	CALL XRYOPN('S')                   ! open XRAY.XRY shared readonly
	IF(IERR(5).NE.0) THEN              ! error opening XRAY.XRY
		CALL ERRMSG('OPNXRY',XRYFIL,1,COMAND)
		GOTO 99999
	ENDIF
	CALL XRYHED                        ! read records 1..3 of XRAY.XRY
	IF(IERR(5).NE.0) THEN              ! error during read
		CALL ERRMSG('XRYHED',XRYFIL,1,COMAND)
		CALL CLOXRY
		GOTO 99999
	ENDIF
	IFLAG=1                            ! check only the D500 #
C
C---- siemens code
C
 10	TYPE 14
 14	FORMAT(//' Which diffractometer? ',$)
C
	READ(*,24,END=99999) DIFNUM,DIFVER
 24	FORMAT(I2,X,A)
	IF(DIFNUM.EQ.0) GOTO 99999
	IF(DIFVER.EQ.' ') DIFVER='A'
	CALL XRYCHK(IFLAG,IREC,DIFNUM,DIFVER)  ! do this check
	CALL DEVATA
	GOTO 10
C
99999	CALL CLOXRY                        ! close XRAY.XRY
9999	CALL LIB$DO_COMMAND(COMAND)
	END
