txt2dfm

I want to find an application, it can make Delphi 5 txtForm format to Delphi 4 dfm format.

I can find dfm2txt, but where can I find txt2dfm?
cookeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
A conversion from DFM (binary Delphi Form file) to a text
 file is done easily using the function ObjectResourceToText.
  For the opposite direction, use ObjectTextToResource.

The following code sample packs the whole task in a
 handy function.
Usage:

// convert a DFM file to TXT
ConvertFormOrText('e:\temp\unit11.dfm', ConvertToText);

// vice versa, extension is not necessary
ConvertFormOrText('e:\temp\unit11', ConvertToDFM);

   
 type
  TDFMorTXT = (ConvertToForm, ConvertToText);

{ Given a file name this routine will convert the file from either
  1. A text file to a DFM file or
  2. A DFM file to a text file
  The output file name is built from the input file name }
function ConvertFormOrText(FileToConvertFrom : string;
                           ConversionType : TDFMorTXT) : boolean;
var
  InputStream, OutputStream : TFileStream;
  FileToConvertTo : string;
begin
  Result := True;
  FileToConvertTo := FileToConvertFrom;

  { change file extensions as appropriate }
  case ConversionType of
    ConvertToForm:
    begin
      FileToConvertFrom := ChangeFileext(FileToConvertFrom, '.TXT');
      FileToConvertTo := ChangeFileext(FileToConvertFrom, '.DFM');
    end;
    ConvertToText:
    begin
      FileToConvertFrom := ChangeFileext(FileToConvertFrom, '.DFM');
      FileToConvertTo := ChangeFileext(FileToConvertFrom, '.TXT');
    end;
  end;

  try
    try
      { Create a file stream for the specified file }
      InputStream  := TFileStream.Create(FileToConvertFrom, fmOpenRead);
      OutputStream := TFileStream.Create(FileToConvertTo, fmCreate);

      { Now perform the selected conversion }
      case ConversionType of
        ConvertToForm : ObjectTextToResource(InputStream, OutputStream);
        ConvertToText : ObjectResourceToText(InputStream, OutputStream);
      end;
    except
      On EStreamError do Result := False;
    end;
  finally
    InputStream.Free;
    OutputStream.Free;
  end;
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwilson032697Commented:
Nice code Barry. Personally I prefer to use convert.exe in the Delphi bin directory... :-)

Cheers,

Raymond.
0
cookeyAuthor Commented:
Thanks very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.