System Functions
ENV( ) Get Environment Values
 
Formats 1. Using Numeric ID: ENV(env_id[,ERR=stmtref])
 
2. Using String ID: ENV(env_name$[,ERR=stmtref])
 
Where:
env-id
Program line number or statement label to which to transfer control.
 
Returns Value of an environment variable
 
Description Use the ENV( ) function to obtain the value of an environment variable (specified numerically or in a string) from the externally defined environment table. Environment variables are typically external to ProvideX and are used by the operating system and other utilities for defining the user's environment.
 
Format 1 Using Numeric ID
 
ENV(env_id[,ERR=stmtref])
If env_id exceeds the size of the Environment Table, ProvideX returns Error #41: Invalid integer encountered (range error or non-integer). Otherwise, ENV( ) returns the current value of the given environment variable.
 
The following program displays all the environment variables:
 
0010 LET I=1
0020 LET X$=ENV(I,ERR=0050)
0030 PRINT X$
0040 LET I=I+1; GOTO 0020
0050 STOP
-:run TEMP=C:\WINDOWS\TEMP PROMPT=$p$g winbootdir=C:\WINDOWS
COMSPEC=C:\WINDOWS\COMMAND.COM CLASSPATH=.;c:\COREL\OFFICE7\SHARED\BARISTA;c:\COREL\OFFICE7\SHARED\TRUEDOC LD_LIBRARY_PATH=c:\COREL\OFFICE7\SHARED\TRUEDOC\BIN PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\COREL\OFFICE7\SHARED\TRUEDOC
\BIN;C:\SOFTWARE\WP60;C:\OTHER\BAT;C:\SOFTWARE\WINSIM\CA_APPSW CMDLINE=WIN
windir=C:\WINDOWS BLASTER=A220 I5 D1 H5 P330 T6
 
Format 2 Using String ID
 
ENV(env_name$[,ERR=stmtref])
If env_name$ does not match an environment variable, the ENV( ) function returns a null ("") string. Otherwise, the function returns the current value of the given environment variable.
 
The following program tests and displays the environment variable TERM:
 
0010 T_TYP$=ENV("TERM")
0020 IF T_TYP$="" THEN PRINT "No terminal defined";
0020: STOP
0030 PRINT "You are using a "+T_TYP$+" terminal"