This tutorial should work with all versions of Delphi, but has been tested with: Delphi 3 Delphi 5 Delphi 6 Delphi 7

Some time ago, a visitor to the message board pointed out that the code which you can download for the tutorials at this site did not work with older versions of Delphi. The visitor was completely correct, the code didn't work, and I promised to sort this out immediately. So, in traditional delphigamedev.com style, months later, I have! The problem is easily fixed, and I had thought that the code I had uploaded when the site was re-launched back in the Autumn, had been made compatible.

I was wrong of course, but having looked around other Delphi message boards it seems that many people are unaware as to just what it is about saving a Delphi program in version 5, 6 (and now 7) that makes you unable to load it in an older version. What follows is just such an explanation, which I hope you will find useful if you have problems in the future with code you've downloaded from another source. At least you'll know what to ask the person who has provided the code to do so you can get it working!

Back when version 5 of Delphi was released, Borland decided to change the default way in which a form file is saved. Previously, they were saved in binary format, but now they were to be saved as text files (much like unit files are). This has the advantage of making it easier for other programs to manipulate forms if they so wanted, but it meant that anyone who saved their code in Delphi 5 (and now Delphi 6 and 7), would be unable to open the file in Delphi 1, 2, 3 or 4. They could view the source code easily, but the form would refuse to open, instead giving you an error message not to dissimilar to that shown below, of 'Error creating form: Invalid stream format.'

This error message is basically trying to tell you that it can't read the form file (.dfm).

Luckily, there is an easy way to sort out your code so that it can be made compatible again, and you never have to see that error message ever again. The catch here is that you need access to a copy of Delphi 5, 6 or 6 to be able to do this, although once you've made the alterations you're in the clear.

So, once you've opened your code in Delphi 5, 6 or 7, you need to select your form. Then, it's just a matter of right-clicking anywhere and selecting the option 'Text DFM' which should be ticked before you click it, and unticked after you've clicked it. Now when you save your code you suddenly have backward-compatible code again! Easy, and if you never want Delphi to save a file in text format again, you can go to the Tools menu, select Environment Options, and untick the box that says 'New forms as text'. Now, whenever you create a new application or add a form to an existing project, it'll be saved in binary format.

A note if I may...
Everything described above should help you out in most cases with your code. You may however find that if you've made use of a property in your code that wasn't available previously, you may have to make some adjustments. This tutorial isn't the be all and end all of making your code backward compatible, but it goes some way to sorting the most common problem.

For the most part though, you're now back in business with your code under older versions of Delphi. It may seem strange to have a tutorial on how to undo a new feature of Delphi, but there you go. If you have any questions, or if you notice a file that still isn't compatible (hopefully not), then the message board is your best bet so that other users of the site can learn from any response I give. An e-mail to me is just as acceptable though.

Subscribe to the feed delphigamedev.com NEWS Feed
archived news | mailing list

[ all tutorials found at delphigamedev.com are Copyright © 2008 Ben Watt ]