	.TITLE	FTSTOP	EXIT FTCOPY WITH THE APPROPRIATE STATUS
	.IDENT	/V1.0 2-MAY-83/
;
;	Routine used to build an exit message from the "SS$_NORMAL" message
;	and the highest severity encountered in the execution of FTCOPY.
;	The exit is done with the "inhibit message" bit set so that no message
;	is printed.  This routine also closes any open input RMS file
;	before exiting.
;
;	CALLING SEQUENCE:
;		CALLS	#0,G^FT_STOP	; All information is passed through
;					  the FT Control Block.
;	REGISTER USAGE:
;	All registers are used as passed from the calling routine.  As this
;	routine terminates the execution of FTCOPY, little care need be taken
;	with preserving the register contents.  No registers are saved on
;	entry.  Internal register usage is:
;		R0 - Used to check status and to build the exit status.
;		R1-R9 - Not used.
;		R10 - Pointer to the FTCB.
;		R11 - Pointer to the FTIO block.
;		
;
	FTCBDEF
	$STSDEF			; SYSTEM STATUS DEFINITIONS.
	$SSDEF			; SYSTEM MESSAGE DEFINITIONS.
	$FABDEF			; FAB DEFINITIONS.
	$NAMDEF
;
	.ENTRY	FT_STOP,^M<>		; SAVE NO REGISTERS.
;
; 		MESSAGE ABOUT NUMBER OF FILES COPIED.
	CALL_MSG	PUT_SYS,#FTC_FILECOP,#1,FTCB_L_FILCOP(R10)
;
	BBS	#FLAG_V_FTIN,FTCB_W_FLAG(R10),5$	; IF FT, SIMPLY EXIT.
;
;		RMS INPUT FILE, WE NEED TO CLOSE IT.
;
	$CLOSE	FAB=IN_FAB
;
;		SECTION REMOVED 6/9/83 - PROBABLY BETTER NOT TO CALL
;		ROUTINE WHICH CALLED THIS ROUTINE.
;
;	BLBS	R0,5$		; IF OK, EXIT.
;
;	CMPL	#RMS$_IFI,R0		; CHECK FOR NO FILE TO CLOSE.
;	BEQL	5$			; IN NONE - INTERNAL FILE IDENTIFIER
;					; ERROR - THEN SKIP THE MESSAGE.
;
;	MOVAL	IN_NAM,R8		; GET NAB BLOCK ADDRESS.
;	MOVZBL	NAM$B_ESL(R8),R5	; GET EXPANDED STRING LENGTH
;	CALL_MSG	PUT_SYS,#FTC_RMSERROR,#4,MSG_12,MSG_12+4,-
;		R5,NAM$L_ESA(R8),R0,IN_FAB+FAB$L_STV		; BAD CLOSE.
;
;		SET UP EXIT SEVERITY AND INHIBIT ANY MESSAGE PRINTING
;
5$:	MOVL	FTCB_L_SEVERITY(R10),R0
	BISL2	#STS$M_INHIB_MSG,R0	
;
;		EXIT THE PROGRAM.
;
	$EXIT_S	R0
	.END
