Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-04

Testing existence of a file at compilation time

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

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]
Sven Barth
to Mark Morgan Lloyd

Am 26.04.2012 11:21 schrieb "Mark Morgan Lloyd" <

: 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.

That's currently not possible.

I've just checked the 2.6.0 manuals: where are things like {$if

declared() defined?

It's in the Programmer's manual:
http://www.freepascal.org/docs-html/prog/progsu112.html#x124-1250002.4.1

Regards,
Sven