36.7 Environment Variables

: val = getenv ("var")

Return the value of the environment variable var.

For example,

getenv ("PATH")

returns a string containing the value of your path.

See also: setenv, unsetenv, isenv.

: tf = isenv (var)

Return true if the variable var is an environment variable, and false otherwise.

For example,

tf = isenv ("PATH")

will typically return true on UNIX systems because "PATH" is an environment variable for UNIX.

See also: getenv, setenv, unsetenv.

: setenv ("var", value)
: setenv (var)
: putenv (…)

Set the value of the environment variable var to value.

If no value is specified then the variable will be assigned the null string.

Programming Note: putenv is an alias for setenv and can be used interchangeably.

See also: unsetenv, getenv, isenv.

: unsetenv ("var")
: status = unsetenv ("var")

Delete the environment variable var.

Return 0 if the variable was deleted, or did not exist, and -1 if an error occurred.

See also: setenv, getenv, isenv.

: homedir = get_home_directory ()

Return the current home directory.

On most systems, this is equivalent to getenv ("HOME"). On Windows systems, if the environment variable HOME is not set then it is equivalent to fullfile (getenv ("HOMEDRIVE"), getenv ("HOMEPATH"))

See also: getenv.