The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    • RT @crypt0ad: Genealogy database Ancestry.com is selling 75% of itself to Blackstone Group for $4.7billion in deal that will giv… 23 minutes ago
    • RT @SethAbramson: MAJOR BREAKING NEWS: Kanye West Presidential Bid Revealed As Highly Coordinated Republican Operation to Suppress Black Vo… 47 minutes ago
    • RT @robinhouston: This is … It was easier to RENAME ALL THE GENES than to persuade biologists to use software that doesn’t mangle gene nam… 47 minutes ago
    • RT @parool: Scholen moeten dringend de ventilatie verbeteren voordat het winter wordt en de ramen niet meer open kunnen. Dat stellen deskun… 48 minutes ago
    • RT @arjenUSA: New York neemt rigoreuze stap. Bij bruggen en tunnels worden checkpoints opgesteld om ervoor te zorgen dat bezoekers uit 35 s… 48 minutes ago
  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,042 other followers

Delphi – backwards compatibility: using {%File to add non-Delphi files to your project in the .dpr

Posted by jpluimers on 2009/07/27

When you add a non-Delphi file to your project, the current (Galileo based) IDE’s add them only to your .dproj file.
But older Delphi’s used to add them to the .dpr file using the (undocumented) {%File pseudo-directive.

When including the file ..\src\Defines.inc, you need this pseudo-directive: {%File ‘..\src\Defines.inc’}

The .dpr import wizard knows about it: if you have a lonely .dpr file using the {%File pseudo-directive, it will be correctly reflected in the .dproj file.

In order to maintain compatibility with old Delphi versions, or if you do not want to ship (version specific!) .dproj files, it can be wise to add your non-Delphi items manually using the {%File pseudo-directive.

Note there are more (equally undocumented) pseudo-directives like {%DelphiDotNetAssemblyCompiler, which I might get back to a later time.

Sample code:

[SourceCode language=’Delphi’]
program InterfacedDataModulesProject;

{%File ‘..\src\Defines.inc’}

uses
FastMM4 in ‘..\src\FastMM4.pas’,
FastMM4Messages in ‘..\src\FastMM4Messages.pas’,
MainUnit in ‘..\src\MainUnit.pas’,
Forms,
MainFormUnit in ‘..\src\MainFormUnit.pas’ {MainForm};

{$R *.res}

begin
Main();
end.
[/SourceCode]

This is the relevant section of the .dproj file:

[SourceCode language=’xml’]




MainSource





MainForm






[/SourceCode]

(Yes, I will post about FastMM in a future blog article, and about interfaces and datamodules even further on.)

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: