?
Solved

$define, different setting within different software projects

Posted on 2009-05-06
4
Medium Priority
?
235 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 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)

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

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

743 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