C-------------------------------------------------------------------C
C Rename a file.                                                    C
C	Note: Multiple (Tagged) files would be nice, but the 
C		checking would be a real pain.
C-------------------------------------------------------------------C
        Subroutine DM_Rename
        Implicit Integer*4 (A - Z)
        Integer*2 Nbytes
        Integer*4 Stat
        Character*1 Maybe
        Include 'Common.Dat'
        Character*(Files_Display_Width) NewName
        Character*(Files_Display_Width) TN
C-------------------------------------------------------------------C

        Call GetName(Current_Line, TN, Itsa_Dir)
         	K = lib$matchc (' ', TN)
	 	If (K .EQ. 0) K = Files_Display_Width

	If (Itsa_Dir) then
     		Maybe = 'N'
     		Call Mess_Get1Char
	1     (' Do you really want to RENAME Directory File '//
	2	TN(:K)//' ??? (Y/N) [N]',
	3		Maybe)

		If ((Maybe .EQ. 'Y') .OR. (Maybe .EQ. 'y')) then
			GoTo 100
		Else
			GoTo 9999
		End If
	End If

100    	Call Get_Answer_Line23(' Enter new Filename for: '//
	1		TN(1:K),NewName,NBytes)

       	If (NBytes .EQ. 0) goto 9999 ! get out if no name entered

   	Stat = Lib$Rename_File (TN, NewName)

   	If (Stat .NE. 1) then
     		Call Mess_Wait(' Can''t rename '//
	1		TN(1:K)//' To '//NewName)
    	Else
		Call SMG$Erase_Line (Files_Display,Current_Line,1)
	     	Call SMG$Erase_Line (Attributes_Display,Current_Line,1)
             	ReLoad = .TRUE.
    	End If

9999    Return 
        End

