C**********************************************************************
C
	SUBROUTINE IFLOAD( IQUIT)
C
C	MOVE TO A CONVIENIENT ANGLE AND WAIT UNTIL SAMPLE IS LOADED.
C	INITIALIZE INTERFACE IF NECESSARY
C
C	Sample will be unloaded by IFEXIT.
C
C	If there is an automatic sample changer this is the place to
C	control it.
C
      INCLUDE 'COMMON.FTN'
C Uses IRD, ITYP, ITIM, IDAT, IFSTAT & SETANG
C Calls IFINIT, IFMOVE & SYTIME
C
C======================================================================
C
C  Initialize interface if necessary.
	IF( IFSTAT.LE.0) CALL IFINIT( IQUIT)
	IF( IFSTAT.LE.0) GOTO 9500
C
C  Move to a nice angle.
	CALL IFMOVE( SETANG, 0.0)
C
C  Wait for sample to be loaded.
100	WRITE(ITYP,104)
104	FORMAT(' Load sample, open shutter then press ',/,
     &   ' S to Start or E,I,D,M,? for other options :',$)
C
C  Read answer.
	READ(IRD,204,END=9500) IANS
204	FORMAT(A1)
C
C  Lots of valid responses (See format statement below)
	IF( IANS.EQ.'S' .OR. IANS.EQ.'s' .OR.
     &    IANS.EQ.'R' .OR. IANS.EQ.'r') GOTO 1000
	IF( IANS.EQ.'E' .OR. IANS.EQ.'e' .OR.
     &    IANS.EQ.'X' .OR. IANS.EQ.'x') GOTO 9500
	IF( IANS.EQ.'I' .OR. IANS.EQ.'i') GOTO 2000
	IF( IANS.EQ.'D' .OR. IANS.EQ.'d') GOTO 3000
	IF( IANS.EQ.'M' .OR. IANS.EQ.'m') GOTO 4000
	IF( IANG.EQ.'^') GOTO 5000
C
C  Response wasn't one of the standard so print the valid responses.
	WRITE(ITYP,254)
254	FORMAT(' If you don''t want to push S or E you might try',/,
     &   ' R for Ready (same as S for Start)',/,
     &   ' X to eXit, A to Abort, E to Exit (all the same as ^Z)',/,
     &   ' If you really want to get  fancy you might even try',/,
     &   ' I to Initialize the interface again',/,
     &   ' D for Debug or',/,
     &   ' M for Move.')
	GOTO 100
C
C   Ready to go.
1000	IQUIT = 0
	GOTO 9999
C
C  "I" means initialize the interface again.
2000	CALL IFINIT
	GOTO 100
C
C "D" means set debug flags
3000	CALL DEBUGF
	GOTO 100
C
C "M" means move to another angle
4000	WRITE(ITYP,4004)
4004	FORMAT(' Enter angle to move to: (F8.3) ?',$)
	READ(IRD,4014) TANGD
4014	FORMAT(F8.3)
	IF(TANGD.EQ.0.0) GOTO 100
	CALL IFANGL(TANGD, TANG)
	CALL IFMOVE(TANG, 0.0)
	GOTO 100
C
C
5000	WRITE(ITYP,5004)
5004	FORMAT(' OOPS.  Let me explain something.',/,
     &   ' Usually the ^ character is used to represent the control',/,
     &   ' key.  ^Z means hold down CTRL (or CONT) and hit Z.')
C
C   Run aborted
9500	IQUIT = 1
	WRITE(ITYP,9504)
9504	FORMAT(' RUN CANCELED.')
C
C  Note that next call ifmove should look to see if X-rays are on.
9999	IFSTAT = +2
	RETURN
	END
