[fpc-pascal] Testing existence of a file at compilation time

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Thu Apr 26 11:21:07 CEST 2012


Is it possible to test for the existence of a file, directory or package 
at compilation time, i.e. {$if exists() or similar?

The specific scenario I'm looking at is where I want to publish a couple 
of projects on Berlios, and the functionality will differ depending on 
whether a particular (Lazarus) package is available: as an example, 
character-by-character (not syntax-defined) colouring which I don't 
think I can do in any standard text-output controls. If at compilation 
time it was possible to detect that a package was available, it would 
then be possible to enable the code that at runtime created a graphical 
component from that package without any intervention on the part of the 
user building the app.

I've just checked the 2.6.0 manuals: where are things like {$if 
declared() defined?

I note that the FPC documentation pointed to at 
http://wiki.lazarus.freepascal.org/Lazarus_Documentation#Free_Pascal_Compiler_Documentation 
is still 2.2.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list