Mail Archives: djgpp/1997/06/25/21:04:22
In article <33B013CC DOT E452725B AT po DOT uni-stuttgart DOT de>,
Martin DOT Bernreuther AT po DOT uni-stuttgart DOT de says...
>
>Hi,
>
>I like to write a small tool to add a path to the PATH variable
>only if it's not already in.
>How can I get a hold of the environment variables?
>Is there already a tool to do this?
>Is there maybe a tool just to search a environment variable for
>a string?
>
I know how to do it in a batch program, though it doesn't have much to do
with DJGPP!
eg TEST.BAT
if %ABC%=XYZ goto ALREADY_DONE
SET ABC=XYZ
ECHO I just set the environment variable
REM do other stuff too if you want
goto END
:ALREADY_DONE
ECHO The environment variable was already set.
:END
It's cumbersome and there's probably a more elegant way, but you could try
using a 'system' statement (I have not tried this, and I don't even know
if it works outside of a batch file)
system("if not %ABC%=XYZ set ABC=XYZ");
Mike.
--
Don't just hit "reply" - my E-mail address is bogus
to avoid automatic browsers from sending junk mail.
Please use collim'at'anubis'dot'network'dot'com
Actually, even this doesn't stop all of them ...
- Raw text -