getenv
fetch the contents of a system environment variable
Calling Sequence
Parameters
Description
Examples
getenv(name)
getenv(regentry,registry) (Windows only)
name
-
the name of the environment variable to fetch
regentry
a list of three strings, the registry key, the value path and value name
Looks up the specified system environment variable and returns its value as a Maple string. If the specified variable is not defined, getenv will return NULL.
A system environment variable is one that is set in the shell from which Maple was invoked. For example, under the UNIX C Shell, such variables are assigned using the setenv command. Under MS-DOS, such variables are assigned using the set command.
The set of available environment variables, and their meanings, is operating system dependent. Maple procedures or worksheets that make use of the getenv function will not likely be portable between versions of Maple for different operating systems.
Note: Issuing a shell command (via Maple's system function) to set the value of an environment variable will not be reflected in subsequent calls to getenv. This is because the system function spawns a sub-shell, and changes to a sub-shell's environment will not affect the shell from which Maple was invoked.
In the Windows versions of Maple, getenv can also be used to query values from the Windows registry. In this case, the first argument is a list of three strings, the registry key ("HKEY_LOCAL_MACHINE", "HKEY_CURRENT_USER", etc ), the value's path and the value's name and the second argument is the name registry.
getenv⁡HOME
/u/joeuser
This is only valid on a Windows system
getenv⁡HKEY_LOCAL_MACHINE,Software\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon,DefaultUserName,registry
joeuser
See Also
system
Download Help Document