The Conditional Compilation - Part 1 article is what you should read before you continue.
As hinted in the Part 1 of this article, conditional compilation let's you tell Delphi compiler to include or not include parts of your code depending on the existence of conditional symbols.
As explained, some conditional symbols, like "DEBUG" and "WIN32" are pre-defined in Delphi.
If you want to be able to easily have two different executable files for your program (therefore produce two different applications using the same code base), let's say "TRIAL" and "normal", you could define a conditional symbol "TRIAL_VERSION", then have lines of code like:
Caption := 'This is a TRIAL version, buy the full one to have all the features!"';
Therefore, the question is: how to define a custom conditional symbol (like "TRIAL_VERSION")?
Build Configuration: Release + TRIALFor the sake of simplicity, let's say you want to have a special "RELEASE" version of your program. The normal RELEASE will build your normal application, the executable will have name as specified by the project (dpr) file. The, let's call it, TRIAL RELEASE will create a differently named executable that will be the trial version of your application where some features are not allowed.
For the above, we want to have a special release version where our custom conditional symbol "TRIAL_VERSION" is defined.
We will define the TRIAL_VERSION conditional symbol as a part of a special extension to the existing RELEASE build configuration. Here's how:
- Expand the "Build Configurations" node under "Project1" in "ProjectGroup1" inside the Project Manger,
- Right click the "Release" build configuration and select "New Configuration..." from the popup menu.
- Let the name for the new configuration build be "TRIAL" on the New Build Configuration dialog.
- The TRIAL is now a sub-node to the Release build configuration node.
Let's now see how to add our custom conditional symbol "TRIAL_VERSION" to the "TRIAL" build configuration.