Reads the value of an environment variable from the environment table of the calling process.
The function
environment-variable
reads the environment variable specified by
name
and returns its value, or
nil
if the variable could not be found.
A
setf
method is also defined, allowing you to set the value of an environment variable:
(setf (environment-variable
name
)
value
)
If
value
is a string, then
name
is set to be
value
. If
value
is
nil
then
name
is removed from the environment table.
In this first example the value of the environment variable
PATH
is returned:
(environment-variable "PATH")
The result is a string of all the defined paths:
"c:\\hqbin\\nt\\x86;c:\\hqbin\\nt\\x86\\perl;c:\\hqbin\\win32;c:\\usr\\local\\bin;C:\\WINNT35\\system32;C:\\WINNT35;;C:\\MSTOOLS\\bin;C:\\TGS3D\\PROGRAM;c:\\program files\\devstudio\\sharedide\\bin\\ide;c:\\program files\\devstudio\\sharedide\\bin;c:\\program files\\devstudio\\vc\\bin;c:\\msdev\\bin;C:\\WINDOWS;C:\\WINDOWS\\COMMAND;C:\\WIN95\\COMMAND;C:\\MSINPUT\\MOUSE"
In the second example, the variable
MYTZONE
is found not to be in the environment table:
(environment-variable "MYTZONE")
NIL
It is set to be
GMT
using the
setf
method:
(setf (environment-variable "MYTZONE") "GMT")