environ - environment variable utilities


#include <basic/string.h>
#include <basic/type.h>
#include <basic/generic.h>

struct string *str;

struct string envirS(type, generic)
int type;
union generic *generic;


These functions manipulate the environment variable list (see environ(5)). 

Envir edits the environment variable given by the string pointed to by str.  The string is of the form “name=value” where name is the name of the variable and value is the value assigned to the variable.  The end of the value is denoted by the end of the string or by a semicolon.  Blanks or tabs before or after the equal sign are ignored.  If an entry whose name matches name appears in the environment variable list, it is first deleted.  Then if value is not empty, an entry of the form “name=value” is appended to the end of the list.  This function implements the ENVIRON statement. 

EnvirS returns from the environment variable list the entry given by type, generic (see generic(inc)).  If type, generic is a string, this function returns the value associated with the name that matches the string.  If type, generic is an integer, this function return an entry of the form “name=value” using the integer as index into the list.  The list is numbered starting with one.  If the integer is too large, this function returns an empty string.  If type, generic has any other type, it will be treated as an integer and thus misinterpreted.  This function implements the BASIC ENVIRON$ function. 


environ(stmt), environ$(func)
environ(5) in the UNIX Programmer’s Manual


Envir generates error 5 (Illegal function call) if name is empty or the equal sign, value and semicolon are all omitted. 

EnvirS generates error 5 (Illegal function call) if type, generic is a string and is empty or contains a blank, tab or equal sign or if type, generic is an integer and is not positive. 

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber