Delphi .PAS code reverts to the previous code after compile/build

775 views Asked by At

I have a .BPG project which has a collection of .DPR project files.

  1. Opened a .PAS file
  2. I changed some line of code in a .PAS file of an project.
  3. Saved it
  4. After changing the source code, I tried COMPILE on that project.
  5. First it says "Compiled" successfully.
  6. Now I see the same .PAS file, the changes were lost. Codes changed at step 2 was lost. It is having the previous code only.

    The behavior is same for BUILD too. Anyone knows about this problem?

Thanks in advance.

Update

One more hint:

.DPR Project Name is XX.dll In IDE, there is one file with name XX_TLB.PAS in that project. In this file only I tried to change some code, which got reverted after compiling/building. Now I tried to rename this file, which gave me a error message

Type Libraries must have the tlb extention.

Also can the .DCU and .PAS files be in the same directory? I entered this directory (where both .PAS and .DCU files exist) into the directories list under "Tools->Options->Delphi Options->Library - Win32"

2

There are 2 answers

0
LU RD On BEST ANSWER

XX_TLB.PAS files are protected files. Do not edit such files directly. In fact there is note on top of the file warning you from editing the file.

They are regenerated each time the type library is refreshed.

See Code Generated When You Import Type Library Information.

This refresh could be done by the IDE each time you compile/build your dll.


You will never edit this file because of the dependencies of a type library and registered com objects. Either you change the com object itself via the type library editor, or create a new unit that interacts with your ActiveX class.

0
David Heffernan On

The Delphi IDE doesn't undo changes, as a general rule. There's notable exception. When you create an empty event handler, and then save the source file, the IDE will remove that event handler. Perhaps that's what is happening.

The other possibility that occurs to me is that you have multiple copies of the file. I've known the following to happen:

  1. You create a package containing Unit1.
  2. You install the package.
  3. You then make another project that contains a different Unit1. Perhaps a copy of the file in a different location, so that it looks like the same unit.
  4. You then modify the copy of Unit1, but the IDE sometimes prefers to open the file from the package.

The bottom line is that beyond deleting empty event handlers the IDE won't undo your changes. So it seems extremely likely that you have multiple copies of the file. To get to the bottom of this, you need to get the full path to the file. In the IDE, hover over the tab with the filename and the IDE will display the full path in a hint. I suspect you'll find that you have two distinct files.