Conditional Uses Clause Considered Harmful

Everyone writing Delphi code that is meant to compile under different Delphi versions has come to the point where conditional compilation seems unavoidable. Ever so often it tends to creep into the uses clauses as well. So, what can we do when units like System.Actions and System.ImageList simple aren’t available in older Delphi versions?

Solution 1: Add an empty unit with the proper name to the project. You might end up with a collection of empty units in your version control system. But hey, it does the job.

Solution 2: Add a unit alias to the project, mapping the unknown units to existing ones you are using anyway. For the two units mentioned above some good candidates are:

  • System.Actions=Vcl.ActnList (for versions below XE3)
  • System.ImageList=Vcl.ImgList (for versions below XE8)

There are a couple of tools that fiddle around with your uses clause from time to time. They will thank you for getting rid of conditions there.

Posted in Delphi, Programming | 5 Comments

Package Magician v1.0.4 and Selective Debugging v1.0.4

Package Magician has got some small fixes in version 1.04:

  • Fix: Closing a project and opening another one doesn’t trigger the active project change event and thus wasn’t recognized, leaving the loaded packages in an unwanted state.
  • Fix: Editing the settings wrote the resolved default path into the settings file.
  • Fix: Setup always showed Delphi 10.1 Berlin enabled, even if it was not installed at all.
  • Fix: Setup now makes the registry settings for All Users, too.
  • Feature: Workaround for RSP-15285

As Package Magician shares the setup with Selective Debugging (despite the app name and app id obviously), those two fixes in the setup are also reflected in Selective Debugging version 1.0.3:

  • Fix: Setup always showed Delphi 10.1 Berlin enabled, even if it was not installed at all.
  • Fix: Setup now makes the registry settings for All Users, too.
  • Feature: Splash screen and About box entry added.

You can find the new versions in the download section.

Update: The Selective Debugging icon didn’t make it into the versions for XE to Seattle. Fixed in version 1.0.4. Nothing else changed.

Posted in Delphi, Programming | Comments Off on Package Magician v1.0.4 and Selective Debugging v1.0.4

Package Magician and Search Paths

Some people using Package Magician or evaluating it asked me to add some sort of search path handling. The usual scenario is that a library installed into the IDE via its setup also adjusts the global library path pointing to the necessary DCU files. Some libraries consist of quite a bunch of packages to be installed into the IDE and thus are not easy to be installed manually, so using the setup is a reasonable option.

Now assume f.i. you have access to the beta version of that library and want to test it with some of your projects, but you still need the release version for your production environment. Let’s further assume you have set up Package Magician to handle the loading and unloading of the respective packages depending on the current project. The problem now lies in the global library path still pointing to either the release DCUs of this library or the beta ones. Continue reading

Posted in Delphi, Programming | 5 Comments

Package Magician v1.0.3

Those of you who use Package Magician (and probably those who don’t yet) may be interested to know that I have uploaded a new version V1.0.3 with the following fixes and enhancements.

  • Fix: The wildcard support in the Forbidden section simply didn’t work. The error crept in during retro-fitting the code for the older Delphi versions where the relevant if-condition was accidentally inverted.
  • Fix: Unloading Package Magician could lead to access violations.
  • Fix: Versions for XE to XE8 were missing the icon.
  • Enhacement: Packages unloaded because they are forbidden are now reloaded when the project changes, except the new project also prohibits that.
  • Enhacement: Packages loaded because they are required are no longer unloaded on project change when they have been originally loaded before.
  • Enhacement: Closing the IDE now restores the original state.

The goal is that Package Magician provides the current project with the correct package environment, but restores the previous state afterwards. It turned out quite tricky to tackle all possible constellations, f.i. when a sequel of projects require a common set of packages. Another potential problem can arise when new packages are added to the IDE while such a project is active. If anyone encounters a misbehavior of Package Magician in some cases, please drop me a line with a detailed description of that scenario.

Download: PackageMagicianSetup

Posted in Delphi, Programming | 2 Comments

There Can Only Be One – At a Time!

Handling Different Versions of Design Packages inside the IDE – Reloaded

This is a follow up of my previous post There Can Only Be One! where I describe the problems encountered when different projects need different packages or versions of loaded into the IDE during design time. In that post I came to the conclusion that the IDE is currently not able to handle this. So I decided to invest some time and wrote a plug in to address this issue. So, Ladies and Gentlemen, we proudly present: Package Magician.

If you have read my post mentioned above – you did read it, didn’t you? – What? You didn’t? OK, so go and read it now. I’ll wait here… – yes, I’ll wait… – I promise! Continue reading

Posted in Delphi, Programming | 3 Comments