Solved

$define, different setting within different software projects

Posted on 2009-05-06
4
229 Views
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'

{$Else}

    RegistryStringPath = 'Software\Version1\Settings'

{$EndIf}

Open in new window

0
Comment
Question by:BdLm
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Hypo earned 500 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)

regards
Hypo
cc.png
0
 
LVL 8

Author Comment

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

Expert Comment

by:Hypo
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.

ex:

implementation
...
{$I 'MyProjectDefines.inc'}
...

regards
Hypo
0
 
LVL 8

Author Comment

by:BdLm
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
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now