Jonathan Elkins
Jonathan Elkins

Reputation: 475

How Do I Use System Variables In Delphi Search Path?

In Delphi XE2 I am setting up a search path. I would like to use a system variable, that I define, to shorten the strings of the various folders used in the search path.

I do it like this:

Search path         : x:\Delphi Library\XTools;x:\Delphi Library\XDiag;
I define variable   : L = x:\Delphi Library
Search path using L : $(L)\XTools;$(L)\XDiag;

If I don't use the defined environment variable, that is write out the path in full, all is well but if i do use the environment variable the compiler does not understand the search path.

I have been using Delphi 3 which is considerably simpler than XE2 so perhaps I'm not specifying either the path or the variable in exactly the right place:

Path is specified here:

Project Manager|Project|Options|Delphi Compiler|Target All Configurations - All Platforms|Search Path

Variable is specified here:

Project Manager|Project|Options|Debugger|Target: All Configurations - All Platforms|Environment Block|User Overrides

Upvotes: 3

Views: 1971

Answers (1)

Rudy Velthuis
Rudy Velthuis

Reputation: 28806

I just did the following, in XE2:

  • In Tools|Options|Environment variables, I defined a user override to the directory of my AutoConsole.pas unit, as new variable L.
  • In the options of a completely new console project, I defined the search path as $(L)
  • added AutoConsole to the uses clause of that project
  • I compiled the project without any problem, and AutoConsole did what it should do: it presented me with a message Press any key... and waited for a keypress.
  • Then I removed $(L) from the search path
  • The program did not compile anymore, because it could not find AutoConsole.
  • I re-added $(L) and the program compiled and worked again.

So what you wanted to do should work. I have no idea what you did wrong, but if you do things like I did, it should work.

Upvotes: 6

Related Questions