C
C  Jim Walker, Aug 1987 for Diffrac-500 with a Radix Databox.
C  Move to the specified 2-theta angle.
C
	SUBROUTINE GOSTAR(ANGLE)
	REAL*4 ANGLE
	CALL GO(ANGLE)
	RETURN
	END
C
	SUBROUTINE GO(ANGLE)
C
	INCLUDE '[102,2]INP.COM/NOLIST'	
	INCLUDE '[102,2]ERRBLK.COM/NOLIST'	
	INCLUDE '[102,2]RAWDES.COM/NOLIST'	
	INCLUDE 'INTERFACE.COM'
	REAL*4 ANGLE
	INTEGER*4 ISTAT, ITIME, I, NCHAR
	PARAMETER CR=CHAR(13)
	CHARACTER BUFFER*255
C
	IERR(5) = 0
C
C  Setup command: Calibrate mode, Goto angle.
	WRITE(BUFFER,4) 13, ANGLE
4	FORMAT('C',a1,'G',F8.4)
C
C  Put in leading zeros so the interface doesn't get mad.
	DO 7,I=4,8
	   IF(BUFFER(I:I).EQ.' ') BUFFER(I:I)='0'
7	CONTINUE
C
C  Send command to interface.
	CALL NULL(BUFFER, 14, ISTAT)
	IF(ISTAT.NE.1) GOTO 9000
	CALL ECHO(CHAR(13), 1, ISTAT)
	IF(ISTAT.NE.-2) GOTO 9000
C
C  Wait for completion
	ITIME = INT( ABS( CURANG-ANGLE)) * 2 + 2
10	CALL READ(BUFFER, NCHAR, ISTAT, ITIME)
	IF(ISTAT.EQ.-1 .OR. ISTAT.EQ.-2) GOTO 10
	IF(ISTAT.NE.1) GOTO 9000
	CURANG=ANGLE
C
C  Get back to monitor mode
	CALL NULL('E'//CHAR(13), 2, ISTAT)
	IF(ISTAT.NE.1) GOTO 9000
	GOTO 9999
C
C  Error return
9000	IERR(5)=127	! interface error
	IERR(4)=ISTAT
	CALL ERRMSG('GOSTAR',RAWFIL,1,BUFFER)
C
9999	RETURN
	END
