SmartPascal
ChangeFileExt
Function
Change the extension part of a file name SysUtils unit
 function ChangeFileExt ( const FileName, Extension : string ) : string;
Description
The ChangeFileExt function changes the Extension value of a file FileName, returning the new value as a string.
Related commands
ExtractFileExt Extracts the extension part of a full file name
ProcessPath Split a drive/path/filename string into its constituent parts
 
Example code : Renaming Unit1.dcu to Unit1.old
var
  oldName, newName : string;

begin
  // Try to rename the current Unit1.dcu to Uni1.old
  oldName := 'Unit1.dcu';
  newName := ChangeFileExt(oldName, '.new');

  // Show the old and new values
  ShowMessage('Old name = '+oldName);
  ShowMessage('New name = '+newName);
end;
Show full unit code
   Old name = Unit1.dcu
   New name = Unit1.new