$define, different setting within different software projects

Posted on 2009-05-06
Medium Priority
Last Modified: 2012-05-06
inside a unit i need different versions of a string constant.

where to put the {$DEFINE LET} command  inside different project mainforms ?
In the project source code ? in the mainForm class definition I tried already and failed
unit ......;
{$IfDef LET}
    RegistryStringPath = 'Software\Version0\Settings'
    RegistryStringPath = 'Software\Version1\Settings'

Open in new window

Question by:BdLm
  • 2
  • 2
LVL 12

Accepted Solution

Hypo earned 2000 total points
ID: 24318944
You don't have to put that DEFINE in your source code (.pas files), Instead you can add it to your project settings. Open your project options dialogue, and then go to Directories/Conditionals, and add Let to Conditional defines... With this way you can tie the define to your projects dof/cfg files instead of the actual source. (the example image is from delphi 7, but you should be able to find it in other versions as well)


Author Comment

ID: 24319166
fine, already working;
would there also be a methode to place it somewhere in the code, may be  more easy to remember ?  
LVL 12

Expert Comment

ID: 24319420
if you want to place it in your code, then you could do it in an .inc file, which you then include in your units where you need to do this test... this inc-file shall then be different for your two project versions... in one version LET will be defined,and in the other it will not.

When you include such a file you do it with compiler directive {$I}, and this should be considered as if the compiler replaced the {$I} directive with the contents of the included file, at that point in your source code.


{$I 'MyProjectDefines.inc'}


Author Comment

ID: 24319454
but this means I have to change the include file once I run the second project, Your first solution seem to be better for me

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question