The environment variables affect the operation of functions. When a process begins execution, an array of strings called the environment is made available. The following external variable points to this vector:
extern char **environ;
In accordance with the XPG4 Version 2 standard, these strings have the form "name=value", e.g. "LAST_BYTE_POINTER=YES"
.
Environment variables in BS2000
You can supply environment variables with default values in BS2000 as follows:
Define the S variable
SYSPOSIX
as a structure:/DECLARE-VARIABLE VARIABLE-NAME=SYSPOSIX(TYPE=*STRUCTURE)
Supply the environment variable name with the value value:
/SYSPOSIX.
name='
value'
Please observe:In BS2000 variable names may only contain uppercase letters and must not contain underscores (_). To define an environment variable with an underscore in its name, you have to convert the underscores into hyphens (-). For example you have to assign a value to the LAST_BYTE_POINTER environment variable as follows:/SYSPOSIX.LAST-BYTE-POINTER='YES'
When a program is started, the S variable SYSPOSIX
is evaluated as part of the environment definition in addition to the defaults for the environment. For each variable of the type string which is contained in the SYSPOSIX
environment variable the string "name=value" is written to the global data area of the program, where name is the name of the environment variable and value is its value. Hyphens are here reconverted into underscores, e.g. the S variable SYSPOSIX.LAST-BYTE-POINTER becomes the environment variable
LAST_BYTE_POINTER.
After having read the S variable the environment variables are administrated in the program only. In particular, modifications of the S variables then no longer affect the execution of the program.
While a program is executed environment variables can only be altered with the putenv
function and be read with getenv
.