[Lazarus] Getting a program's "true name"
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Mon Oct 25 10:25:28 CEST 2010
Marco van de Voort wrote:
>> I use (*$IFDEF LCLGTK2 *) etc. in an "about" box, together with e.g.
>> (*$I %FPCVERSION% *) and (*$I %DATE% *).
>
> An ifdef is a different beast from a {$i }. Defines are set on the cmdline
> (e.g. -dLCLGTK2 in the above case), while $I are
>
> either built in (FPCVERSION, DATE, the easiest is to look up the
> {$i %..%} syntax in the manual for a list)
>
> _or_ an environmentvariable. This can be used to pass content like this, but
> means that lazarus has to set them in the environment that FPC calls.
>
> The advantage of this, is that it will work with any 2.x FPC version.
>
>> Noting that somebody was asking about getting the LCL version a few days
>> ago, where I've had to do this I tend to rely on having a fairly tight
>> fit between FPC and LCL versions.
>
> FPC doesn't know anything about LCL or Lazarus, let alone its exact
> versioning. But it can regurgitate information it gets passed _by_ Lazarus.
> Defines and {$I %environmentvariable%} are examples of this.
The point I was trying to make- which I didn't do very well- was that if
something is usable in an ifdef if can be used to exclude code which is
syntactically wrong for the current compiler, or references public
properties which don't exist in the current LCL.
I don't think that you can do that if you're getting a value from
lclversion or whatever, the decision has- in effect- to be made at a
preprocessor level.
Going back to my original question, can I put something like this
-dprojectname=heavy_wethers
or even
-dprojectname=$ProjFile()
in the project settings, and then use it as
projectName:= {$I %projectname% } ;
--
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 Lazarus
mailing list