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	IMPLEMENTED IN A "RUDIMENTARY" FASHION.  NO CHECKS.
C-------------------------------------------------------------------C
        Subroutine DM_Rename
        Implicit Integer*4 (A - Z)
        Integer*2 Nbytes
        Integer*4 Stat
        Character*1 Maybe
        Include 'Common.Dat'
        Character*80 NewName
        Character*(Files_Display_Width) TN
        Character*255 Temp_Line
C-------------------------------------------------------------------C

	IF (IncluCount .LT. 1) then  ! Rename file at Current_Line 

	        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

C--------------------------------------------------------------------
	ELSE      ! Rename Multiple files into .......

       		Call Get_Answer_Line23(' ReName Tagged Files To:',
	1		NewName,NBytes)       

       		If (Nbytes .EQ. 0) then 
         		Goto 9999
       		Else 
		  If ((Lib$MatchC('[',NewName(:NBytes)) .EQ. 0) .AND.
	1	      (Lib$MatchC('*',NewName(:NBytes)) .EQ. 0)) then 
C				Could be an error.
 	    		Maybe = 'N'
  	   		Call Mess_Get1Char
	1 	    (' Do you really want to Rename EVERY Tagged File '// 
	2		NewName(:NBytes)//' ??? (Y/N) [N]',
	3		Maybe)

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


200	  	    ReLoad = .TRUE.

	  	    Temp_Line = 'RENAME/LOG \\ '//NewName(:Nbytes)
	  	    Nbytes=Nbytes+15
	  	    Call Make_DCL_Line (Temp_Line, Nbytes )
	  	    If (Do_DCL) then 
		 		Call Do_Controlled_DCL
		 		Do_DCL = .FALSE.
	  	    Else
		 		If (Terminator .EQ. SMG$K_TRM_PF1) 
	1				Call Get1Char(Cmd) ! Eat <Gold>
		 		ReLoad = .FALSE.    ! Reset if something was wrong.
	  	    End If
       		End If         

	END IF

9999    Return 
        End

