Sharing a project between two versions - delphi

Delphi is a great IDE and compiler. But sometimes it also has a few minor flaws. Like my problem right now...
I am working on a project that's created in Delphi 2007. But I like to use Delphi XE simply because the IDE has some interesting features and it happens to be more stable on my computer. So I opened the project in Delphi XE and have been changing the code, with backwards-compatibility in mind.
When I save the project again to open it in D2007, it has problems reading the project, though. The dproj file of XE is not compatible with 2007. To open the project in D2007 again, I need to delete the dproj file and open the dpr file. (Or I need to save the old proj file of 2007 and put it back again when I want to use D2007 again.)
This is annoying. Does anyone know a better solution to keep the right dproj file for each version?

One thing you could do would be to place the DPR and DPROJ files in separate directories. Unfortunately you would have to merge any changes you make in one version to the other, but that is fairly simple using Beyond compare:
BCompare.exe .\d2007\project.dpr .\dXE\project.dpr

You can have your project in version control like Subversion. If you omit the .dproj files from version control, it is usually quite manageable to work in different versions of Delphi

I'm using single .dpr and multiple .dproj files in such case.
Basic steps:
- Create project in D2007.
- Close project.
- Copy project.dproj to project.xe.dproj.
- Open project.xe.dproj in XE.
- Let it upgrade the project, save it and overwrite old project.xe.dproj.
- Delete backup copy of project.xe.dproj created during the upgrade.
Now you have project.dproj to use in D2007 and project.xe.dproj to use in XE. Both are using the same codebase - project.dpr.

Related

Can we use a lower version of Delphi (Delphi xe5) to edit a project file from the higher version (Delphi xe6)

Every time I run the .dproj file in xe5, I get an error "Exception EReadError in module StartCoatPro.exe at 000C0304. Error reading LineSeries1.Legend.Visible: Property Legend.Visible does not exist."
I tried looking for the Legend.Visible property under LineSeries1 in the .dfm file but I couldn't find it. Then I also tried to put a line, Legend.Visible = True, but doesn't seem to work too. Please help.
Thanks!
Project files are version-specific. You cannot edit an XE6 project in the XE5 IDE and vice versa, for instance.
But what you are experiencing is not a project problem, it is a DFM problem. You have an XE6 DFM that contains a value for a property that apparently does not exist in XE5. Do not try to edit DFM files across version boundaries, either. Newer versions tend to store new properties that cause errors in earlier versions.
Cross-version project management is tricky. Best not to share version-specific files at all, unless you use third-party tools to help you. For instance, there are tools available that manipulate DFMs to strip out newer properties when downgrading to an older IDE.

Delphi 7 to Delphi XE2 .res file issue

When I open a Delphi 7 Project in Delphi XE2 and open the Project Option I get an error:
"Unable to set Icon: Cannot open file "........\AppName_Icon.ico".
The system cannot find the file specified".
I also notice that the Version info of the Project is missing.
The Delphi 7 project has .Res file that has the MAINICON along with the version information stored.
Why is Delphi XE2 not able to use this .Res file to retrive the MAINICON & Version information.
Also if I try to compile the application in XE2 I get an error -
[BRCC32 Error] MtxReq.vrc(2): file not found: MtxReq_Icon.ico
The MTXReq.vrc file (a new file) is created and the MtxReq.res file is deleted.
Why is this happening? I don't want to loose my project icon and version settings from .res file.
Is there a way to force XE2 to use the .res file and not delete it?
Any help will be greatly appreciated.
Sorry I can't post a comment yet (need more repotation points) ...
Warren - here the reponse to your question (Wouldn't just deleting your .dproj file and keeping the .dpr only, have been faster?)
I deleted the .dproj, .dproj.local
Opened the .dpr in XE2 and it recreated the .dproj file.
It brough back the icon from the .res but I lost project version info. Only File Version and Product Version info got migrated but lost all other versioning info. (This is because of the default manifest file).
I then tried what I explained in Step 1 of my solution.
I open the .dproj file in notepad deleted the tag entries under and reopened the .dproj file and all my version info now was recovered. The problem here is the $(BDS)\bin\default_app.manifest.
Also I noticed that Version info is stored in tag under the tag in the .dproj file and once you delete the default manifest entries, the IDE pickups the version key information correctly from the .
So basically by deleting the .dpr file I skipped the step of extracting and adding the .ico file to the project, but had to edit the newly created .proj file and delete the entries for default manifest to retrieve the version info. (another solution would have been to manully add the version info and saving the project. I did not try this)
Update 2015: Remy's idea of recreating .DPROJ files carefully by hand, is excellent advice and should be considered first, even though my answer is marked accepted.
Delphi versions prior to XE2 used resource files as an INPUT and an OUTPUT in the compilation process. For example, your delphi 7 project icon is embedded in that .res file, which you "want delphi xe2 to use", however, that's problematic in delphi 7, and now flat out impossible in XE2. Instead you now treat the .res file as a pure output artifact, the same as executable files. Don't bother checking .res files into version control any more, and don't try to pretend that the .res file is the place where you permanently store your icons. It's an output file produced automatically by the compiler, as it always should have been.
If you are a modern developer, the old way Delphi 7 worked might have annoyed you (it sure annoyed me) because you have the interesting and unsolveable question about what to do for version control: Do you check in the .RES file, or don't you? There were drawbacks to both approaches, and the fact that .RES files are now output artifacts only in XE2 is for the best. So learn to live with that.
Now that XE2 supports icons not only for a PC but also for a Mac, it must handle things differently, and they have cleaned this up. This is the origin of the problem you're seeing with the .ICO file. I have seen exactly the same error, and I have ignored it, and simply added the icon back to the project after it has otherwise been converted.
Converting a delphi 7 project (.dpr and .cfg) to Delphi XE2 is not as big a problem as the conversions between various levels of .dproj files -- each version starting with Delphi 2005,2007,2009,2010, and onwards has implemented changes in the dproj format. When problems occur with converting these projects, I do not do as Remy suggests, because it's a waste of time. What I do is DELETE the DPROJ and let it convert up from a .dpr file only.
But Remy's advice to start from scratch has many advantages, including that you may simplify your project layout.
Anyways, here's what you do:
Ignore error.
Add icon to project yourself.
Continue merrily along, and don't worry about the deletion of the .res file, that's intentional, and for good reasons. A new one will be created whenever needed. The filename of the .ico file on disk will be read by using the contents of the XE2 .dproj file and compiled into the .res file, as it should be.
As is always the case, you should NEVER let the IDE convert a project from an older version to the newer version. The conversion RARELY works correctly. You should ALWAYS create a new project in the newer IDE and then add your existing source files to it as needed.
Thanks everyone for your inputs and suggestions.
After I submitted my posting, I tried these steps to resolve the .ico issue and the missing Version issue/version info carry over issues :
Step 1. Edited the .dProj file and removed the reference to default_app.manifest related entries under tag (My project platform is 32 bit)
I deleted all tags under this except tag related to namespace System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)
Without this my application was always showing the version info as 1.0.0.0 and ignoring everything else that I had specified.
(I am not sure if this is a right step but it solved my version info issue. There may be a simpler/another solution for this...)
Step 2. Extracted the ico from the old .res file, named it and added that .ico file to the Project from the Project Options.
the physical .ico file is the the projects folder and will be checked in source control (VSS in my case).
These two steps bought me to what I needed and then I can modify the Version number and compile the project.
From this point on there are no issues.
These were much simpler than the total conversion/migration I had to do for my applications from D7 to XE2 - Unicode conversion, migrating customized Raize 5 componets to Raize 6, Turbo Power, Virtual Tree View, Hypergrid etc. etc. etc... Luckily I found XE2 versions of all these components.

Migrating Delphi5 components from Win2000 to Win7(64bit)

Firstly I can't really update the version because I would have to re-write my software which uses the dated components.
I initially had alot of success by re-installing the packages (around 40) to the fresh D5 install on the new Win7 machine. If it told me the .Bpl file was missing it works when I move it to the directory:
C:\Program Files(x86)\Borland\Delphi5\Projects\Bpl
and similarly if the .dcu is missing I move it to the Delphi5\lib directory.
However my next obstacle is when I load any form which has an Advantage table (all of my software uses Adt files and AdsConnections). It gives me the error:
TableX.StoreActive : property does not exist
for many tables and a few more properties including LoginPrompt.
It seems these are not included in my components which were included on my previous installation. I've tried updating to the most recent version of Delphi Sp1 but cannot find any information on how to add these properties.
I've carried out a similar migration: several projects developed in Delphi 5 on XP were moved to Windows 7. Unlike you, I also updated to Delphi 2010 at the same time.
The biggest difficulty I had was the lack of unicode support in my Delphi 5 components - I had to edit a lot of third party code. Of course, if I'd not upgraded to Delphi 2010 I wouldn't have needed to do that. Everything else went swimmingly. Here's how I did it.
First I made a copy of the project on the old machine, went through each form and replaced each of the third-party VCLs with run-time creation. It's a slog writing code to assign all the properties and events, but when I was finished there were only standard Delphi components on my forms but the project still ran correctly. Then I was able to move the project and the third-party .pas files to the new machine, open the project in Delphi 2010 and deal with the unicode issues.
The process was gruelling but straightforward.
Since then I've migrated another older project down the same path, but this time built a new application framework in Delphi 2010 and copied the units across piecemeal. In some cases I used the original .pas and .dfm files, in others I created new forms and copied the functional code. In all these cases I installed into Delphi 2010 the latest equivalents of the original third party components. This took a little longer than the original method.
However you tackle this, best of luck.

How to keep forms and frames compilable in Delphi 6 - 2007?

We recently converted our long-running Delphi project to Open Source. Multiple people have contributed patches already, which is great, but unfortunately forms and frames when saved with Delphi 2006 (and later) contain new properties in the .dfm that are not handled by older versions. Forms are handled quite gracefully by the IDE ("ignore propery?"), but frames are loaded at runtime and result in errors. Not an option, as far as I'm concerned.
I now removed those properties from the .dmf files by hand, but I am really wondering if there is a more elegant solution. There is no way to save in a backwards compatible format from the new IDE's, is there? Are there existing tools to strip the nonsupported properties from the .dfm's ? Any other elegant solution I am missing?
Normally, with a commercial project, I'd just upgrade the project to the most recent version applicable... but as this is open source I really don't want to loose out on those developers still working on Delphi 7. That includes myself, actually.
The JEDI JVCL project uses a little utility dc.exe (delphi cleaner) and a list of properties in DFMs that are not present in older versions of delphi, mine contains the following text:
*.PopupMode
*.PopupParent
*.ExplicitLeft
*.ExplicitTop
*.ExplicitWidth
*.ExplicitHeight
*.BevelKind
*.BufferDocument
*.DoubleBuffered
*.ParentDoubleBuffered
*.DisableHyperlinks
*.AlwaysEnquoteFloats
*.PixelsPerInch
I run this dc.exe utility from a batch file which cleans my dfms before I commit
changes to subversion. The syntax in my batch file for this is:
dc.exe -s -fd10.txt *.dfm -i
You can grab my stuff at:
http://sites.google.com/site/warrenpostma/files
You can try Andy's DFMCheck. It can automatically open and close all forms and frames in a project, which makes the IDE remove unknown properties (as Marco wrote).
Well, for sake of completeness:
Open the dfms in the oldest Delphi supported, let it remove all unknown properties, change a property and save.
For your purposes, Warren's solution is better, but it can be a workaround. I did it for a while when we were dual D7-D2006ing.

Cannot install components that worked under D7 in D2009

I have lots of components that worked perfectly under D7.
I managed to compile and install them by dragging them into the Delphi 2009 IDE.
However, when I try to use those components in a project, the compiler says it cannot find the source code of them.
Where I can enter the path to that library?
Solution:
I dragged and dropped the old DPK file in Delphi 2009. Then in project manager I choose “Build” an then “Install”.
Everything worked smoothly except that the applications that used the controls couldn't see its source.
Problem solved by adding the path into the Tool-Options-Library Win32.
Thanks to everybody and especially to Mohammed.
Have you added the source path of the components to your library path?
you can add it from Tools menu > Options > Library win 32 >Library path
If you've really installed them, then the compiler shouldn't need to find the source code. The compiler only needs the DCU files.
But if you've taken these components from Delphi 7, then you need to have the source code, because Delphi 7 DCU files are not compatible with Delphi 2009. (The only two versions ever that can use each other's DCU files are Delphi 2006 and Delphi 2007, and then only with certain restrictions.)
Trying to use DCU files from the wrong Delphi version will cause Delphi to try to recompile the units. The solution is not just to provide the path to the source code, though. If the units files haven't been compiled yet (and they obviously haven't if they're of the wrong Delphi version), then you haven't really installed anything. Installing components in Delphi has never involved dragging and dropping. Installing a component means installing the package that contains that component, and installing a package often means opening the DPK project file and then choosing the "install" command in the IDE.

Resources