Solved

Conditional compile

Posted on 1998-07-08
4
213 Views
Last Modified: 2010-04-04

Is it possible to use conditional compiling in DFM files (somehow, sice {$IFDEF} doesn't work)?

I need to disable some components like this:
(this is: "View form as a text" source of DFM)

{$ifdef DEMO}
  object Timer1: TTimer
    Interval = 100
    OnTimer = Timer1Timer
    Top = 528
  end
{$ENDIF}
0
Comment
Question by:yuhoo
[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
4 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 1357360
Not possible according to me.

You can disable it programmatically.

Or you can make two forms and make your uses claus contitional:
uses
{$IFDEF DEMO}
  unit1,
{$ELSE}
  unit2,
{$ENDIF}
0
 
LVL 10

Accepted Solution

by:
Lischke earned 50 total points
ID: 1357361
This is not possible at all. What you can do is to specify something like:

{$ifdef ver100}
  {$r D3.dfm}
{$else}
  {$r D2.dfm
{$endif}

and it will compile, but this way you cannot open the formular in the IDE.

So the answer is no.

Ciao, Mike
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1357362
You can't do this in the dfm...but why do you need to...

you can do this in the pas file...and create it dynamically...

{$ifdef DEMO}
  Timer1 := TTimer.Create(self);
  with Timer1 do
  begin
    Interval := 100;
    OnTimer := Form1Timer;
    Top := 528;
  end;
{$ENDIF}

remember to wrap calls to Timer1 in nil checks...i.e. if Assigned(Timer1) then or if Timer1 <> nil then...

Rick
0
 

Author Comment

by:yuhoo
ID: 1357363
What would you do if you wanted to make multi language application with lot of Labels on a Form?
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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