Purge environment variable

Just starting out? Need help? Post your questions and find answers here.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Purge environment variable

Post by horst »

SetEnvironmentVariable("Vdrive","")
should purge the variable. Instead the variable still exists (with empty assignment).
The equivalent API function works correctly.

For example (at the console) the command SET Vdrive
should display:
---- The environment variable is not defined
and not:
---- Vdrive=

Existing, but empty variables may have unpredictable consequences.
Horst.
freak
PureBasic Team
PureBasic Team
Posts: 5944
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Purge environment variable

Post by freak »

Try RemoveEnvironmentVariable()
quidquid Latine dictum sit altum videtur
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Re: Purge environment variable

Post by horst »

freak wrote:Try RemoveEnvironmentVariable()
Sorry, I did not expect this, because I was used to the DOS/Windows behaviour.
Now I always have to remember to use this construct for setting variables:

Code: Select all

If Vdrive
  SetEnvironmentVariable("Vdrive",Vdrive)
Else 
  RemoveEnvironmentVariable("Vdrive")
EndIf 
Edit: .. or use a macro..
Maybe a little hint in the SetEnvironmentVariable help would be helpful.
Horst.
Post Reply