MIAMEX 31: Get environment variable

Updated October 2014; see History

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

MX_GETENV 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 AG_GETENV for samples.

Comments

MX_GETENV 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 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.

History

2014 October, A-Shell version 6.1.1391:  Passing an empty environment variable name parameter now causes MX_GETENV to return the entire list of environment variable definitions, delimited by a chr(10) character between each NAME=VALUE string. Also, you can now specify a dynamic string variable (S,0) for the return parameter, which will expanded as needed.