Solved

$define, different setting within different software projects

Posted on 2009-05-06
4
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

707 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