[Lazarus] Getting a program's "true name"

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Oct 25 10:49:37 CEST 2010


On Mon, 25 Oct 2010 10:31:20 +0200
Marco van de Voort <marcov at stack.nl> wrote:

> On Mon, Oct 25, 2010 at 08:25:28AM +0000, Mark Morgan Lloyd wrote:
> > > 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% } ;

In project1.lpr add

uses FileUtil;

  ProjectName := ExtractFilenameOnly({$I %file%});

 
> Not that I know. Via environment variables is the only way. I thought a
> while back to do this via macros ( -dxxx:=yyy syntax), so that it could also
> be on the cmdline:
> 
> http://bugs.freepascal.org/view.php?id=12935


Mattias




More information about the Lazarus mailing list