This function returns the value of an environment variable. Environment variables are string values associated to names that are provided by the executing environment for the programs. The executing environment is usually the operating system, but it can also be the Web server in CGI programs that alters the environment variables provided by the surrounding operating system specifying extra values.
This function can be used to get the string of an environment variable in case the program knows the name of the variable or to list all the environment variables one by one.
If the environment variable name is known then the name as a string has to be passed to this function as argument. In this case the return value is the value of the environment variable.
If the program wants to list all the environment variables the argument to the function ENVIRON can be an integer number n. In this case the function returns a string containing the name and the value joined by a = sign of the n-th environment variable. The numbering starts with n=0.
If the argument value is integer and is out of the range of the possible environment variable ordinal numbers (negative or larger or equal to the number of the available environment variables) then the function returns undef.
If the argument to the function is undef then the function also returns the undef value.
Note that ScriptBasic provides an easy way for the embedding applications to redefine the underlying function that returns the environment variable. Thus an embedding application can "fool" a BASIC program providing its own environment variable. For example the Eszter SB Application Engine provides an alternative environment variable reading function and thus BASIC applications can read the environment using the function ENVIRON as if the program was running in a real CGI environment.