	LOGICAL FUNCTION SEND_FILE(FILES)
C
C	Routine to send a file to the remote.
C
	INCLUDE 'COM.INC/NOLIST'

	CHARACTER*(*) FILES
	LOGICAL*1 CODE(1)
	LOGICAL GET_VAXFILE, GET_REMFILE
	INTEGER*4 B, S, E

	SEND_FILE = .FALSE.		! Initialize to bad return.
C
C	Parse the file names (if any).
C
	B = 1				! Start at first character.
	CALL PARSE_CMD(FILES,B,S,E)	! Parse the file name (if any).
	IF (.NOT. GET_VAXFILE(FILES(S:E-1))) RETURN ! Get/open the VAX file.
	CALL PARSE_CMD(FILES,B,S,E)	! Parse the file name (if any).
	IF (.NOT. GET_REMFILE(FILES(S:E-1))) RETURN ! Get/open the REMOTE file.
C
C	We're all ready to go ...
C
	CALL INIT_TIMER			! Initialize the timer.
	CALL CLEAR_COUNTS		! Initialize the counters.
	ASSIGN 100 TO LOOP		! Loop reading from file.
	ASSIGN 200 TO RETRY		! Retry after transmission error.
100	IF (CONTROLC_TYPED) RETURN	! Return if aborted.
	READ (FILE_UNIT,110,END=9900) NBYTES,(XBUFFER(I+7),I=1,NBYTES)
110	FORMAT (Q,<NBYTES+1>A1)
C
C	Prepare the record to send the remote.
C
C	Format:  bbbbcccrrr...rrr
C
C	Where:  b = bytecount, c = checksum, r = record.
C
200	IF (CONTROLC_TYPED) RETURN	! Return if aborted.
	CHECKSUM = GET_CHECKSUM(XBUFFER(8),NBYTES) ! Calculate checksum.
	ENCODE (7,210,XBUFFER(1)) NBYTES, CHECKSUM  ! Put it in buffer.
210	FORMAT (I4,I3)
C
C	Write it to the remote and wait for a response.
C
	CALL WRITE_REMOTE(XBUFFER,NBYTES+7)
	CALL GET_RESPONSE(CODE)		! Get response from remote.
	IF (CODE(1) .EQ. CAN) RETURN	! Transmission aborted.
	IF (CODE(1) .EQ. ACK) THEN
		CALL TOTALS(NBYTES)	! Update the totals
		GO TO LOOP		!  and get next record.
	ELSE
		CALL REPORT_ERROR	! Report transmission error
		GO TO RETRY		!  and send the record again.
	ENDIF
C
C	Here for EOF on input.
C
9900	CALL SEND_EOF 			! Send EOF (CTRL/Z) to remote.
	CALL GET_RESPONSE(CODE)		! Get response from remote.
	IF (CODE(1) .EQ. NAK) GO TO 9900! Transmission error.
9910	CALL SEND_EOT			! End of transmission.
C	CALL SETUP_REMOTE(.TRUE.)	! Set remote for interactive.
	CALL GET_RESPONSE(CODE)		! Get response from remote.
	IF (CODE(1) .EQ. NAK) GO TO 9910! Transmission error.
	SEND_FILE = .TRUE.		! Show success.
	RETURN
	END
