Subroutines > Detailed Descriptions > MIAMEX

MIAMEX 31: Get environment variable

Updated June 2008

xcall MIAMEX, MX_GETENV, envvar, value {,flag}

This function retrieves the definition of an environment variable; use MX_SETENV to define environment variables.

Parameters

envvar  (String)  [in]

The name of the environment variable (e.g. "MIAME"). Use of the % delimiters surrounding the name is optional, i.e. "MIAME" and "%MIAME%" are equivalent. Environment variables are not case sensitive under Windows, but they are under UNIX, so it it best to stick with the convention of using all upper case. There is no particular limit to the length of an environment variable name.

value  (String)  [out]

Returns the definition of the specified environment variable. If not defined, returns a null string. There is no particular limit to the length of an environment variable definition. It will truncated if needed to fit into the variable provided.

flag  [in]

If specified and set to 1, then the returned value will be de-mangled—i.e., converted from the DOS 8.3 compressed format to the full long format, if possible. See ?Tab(-10, AG_GETENV) for samples.

Comments

This function only works relative to the system that the program is running on, i.e., it will not retrieve an environment variable definition from the remote telnet client. To accomplish that for ATE, see ?Tab(-10, AG_GETENV).

Environment variables may be defined in various ways depending on the host operating system. Under Windows, you can use the Control Panel “System” applet. Under UNIX, they are set by shell commands, e.g. “MIAME=/vm/miame”. The set command will typically display the current definitions.

In addition to system defined environment variables, A-Shell understands a few special variables which do not have to be set externally. One is “%CurrentDirectory%”, which will return the current working directory in the host operating system. Two others, which are only available under Windows, are “%WindowsDirectory%” and “%SystemDirectory%”, which return the directory spec of the “Windows” and “Windows System” directories. Another two are set by A-Shell when it launches: %MIAME% is the directory where the miame.ini file is, and %MIAMEFILE% is the full path spec of the miame.ini file.