Solved

$define, different setting within different software projects

Posted on 2009-05-06
4
230 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi OLE Error 8 95
Delphi application Soap connection 5 96
Delphi Mdi application Child forms get behind control 7 163
Performance of SQL statement 37 101
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

864 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

21 Experts available now in Live!

Get 1:1 Help Now