The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

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

    Join 4,225 other subscribers

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 )

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: