Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conditional compile

Posted on 1998-07-08
4
Medium Priority
?
217 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 150 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

670 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