Delphi Path Variables
Asked Answered
M

6

9

In the Delphi IDE, the path to the Delphi installation is specified as $(DELPHI). I am wondering if there is a way to create my own path indicators, such as $(MY_LIBRARY) or something similar. I thought $(DELPHI) was specified as an environment variable, but apparently not. Any ideas? (I'm using Delphi 7)

Mesitylene answered 10/5, 2010 at 14:40 Comment(3)
Did you ever find a way to get round this issue in D5 ?Lukewarm
Yep, I switched jobs ;) In all seriousness though, I unfortunately never did.Mesitylene
Think you did right. The functionality only appeared in D6, apparently. How did we ever manage ?Lukewarm
T
10

In Delphi 2010:

  • select Tools -> Options
  • select "Environment Variables"
  • specify either System, either User variable
Territerrible answered 10/5, 2010 at 14:59 Comment(3)
Thanks for the response. I should have specified that I am using Delphi 5, 7, and 2010. It is Delphi 5 that I am trying to do this in. Sorry about thatMesitylene
Delphi 5 does not support user-defined environment variables. That was introduced in Delphi 6.Drops
Thanks Remy. I'll reserve that as just another reason to update all this code to 7 or 2010!Mesitylene
S
1

For Delphi 5 you can add them from windows Environment variables

right click on My computer > properties > advanced > Environment variables

Soaring answered 10/5, 2010 at 16:59 Comment(3)
I did the following: Added system variable with the following info: Variable Name: OUTPUT_DIR Variable Value: T:\Builds And in Delphi, in the Output folder: $(OUTPUT_DIR)\Projects\Bpl This generates the error: Could not create output file $(OUTPUT_DIR)\Projects\Bpl\Amase32.exeMesitylene
You can add as many environment variables as you want, but it won't make any difference. Delphi 5 doesn't recognize environment variables. $(DELPHI) is not an environment variable.Lecce
Rob, that is correct, as I had indicated I discovered in my original question. That said, is there any way to mimic the way ($DELPHI) is used in my own Delphi 5 projects?Mesitylene
O
0

In Delphi 2010: I know many of the XML tags in the Project.dproj can be used like this. (For exemple, $(DCC_DcuOutput), $(DCC_ExeOutput)...).

Maybe it is possible to add your own XML tags in the file and use them afterward. Though I'm not sure if they'll be preserved by the IDE.

Orvilleorwell answered 10/5, 2010 at 15:0 Comment(0)
F
0

Also of note is when your using the command line compiler, the file RSVARS.BAT located in the BIN directory of the current Delphi installation is what creates some of the environment variables for child processes. (for example BDS and BDSCOMMONDIR).

Fargone answered 10/5, 2010 at 15:48 Comment(0)
M
0

In Windows 7 (and Vista is similar) click the 'start' button, right-click 'computer', 'properties' and then 'advanced system settings'. Click 'Environment variables' and you're now able to create new ones as global (system), or just for the current user (you). For example 'MyVar'.

Now in a delphi path, refer to MyVar as $(MyVar).

MyVar will now be visible in batch files too as %MyVar%.

Maryalice answered 10/5, 2010 at 15:48 Comment(0)
B
0

There is an alternative workaround -- use SUBST to assign a virtual drive letter to the root of the folder you would be using $(MyFiles) if you could and then just use that.

For Example if you have files in deep directory, you'd go to the command prompt and type:

SUBST M: "C:\users\Me\Delphi Files\My Components"

and then you could refer to it by M:

Biel answered 7/3, 2016 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.