All Manuals > LispWorks® User Guide and Reference Manual > 38 The LISPWORKS Package

environment-variable Accessor

Summary

Reads the value of an environment variable from the environment table of the calling process.

Package

lispworks

Signature

environment-variable name => value

setf (environment-variable name) value => value

Arguments
name
A string.
value
A string or nil.
Values
value
A string or nil.
Description

The accessor environment-variable accesses the environment variable specified by name and returns its value, or nil if the variable could not be found.

A setter 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.

On non-Windows platforms, the environment variables are encoded as specfied in 27.14.1 Encoding of file names and strings in OS interface functions.

Examples

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")
See also

27.4.2 Accessing environment variables


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:41