Env$
ENV$(<variable>)
The Env$(var$) returns the current value of the environment variable. The Env$ function can be used to obtain the value of any user-created or system-created environment variable that can be displayed with the operating system's SET (or set) command. To see a list of these variables, enter the SET command with no parameters at the operating system prompt.
The Env$ function is used to retrieve an environmental variable's value which was set with SetEnv or inherited from Windows' environmental variables.
Example:
got1$=env$("UserName") got2$=env$("GUIMode")
Additionally the status command showing all set environmental variables is:
Status Env
The Env$ internal function can be set by CONFIG SETENV. For example, use the following command to set the value of env$("librarypath"):
config setenv librarypath f:\apps\library\
Operating system ENV$ variables cannot be set or altered by CONFIG SETENV. Other system Env$ variables will be added.
Comments and Examples
As an example, if LOGNAME contains the login name, the following line in a menu program would require a user to log in as "root" to be able to run program PROG14.
00040 if env$("LogName")="root" then chain "Prog14" else goto SHOWMENU
Technical Considerations
- Unix / Linux versions of Business Rules require that user-created environment variables be passed by an export command to the operating system before the user enters Business Rules . Otherwise, the values of these variables cannot be returned by ENV$.
Env$("GUIMode")
There is a BR provided Env$ variable called GUIMODE (case insensitive). It's value is either ON or OFF depending on whether BR is in GUI mode. System ENV$ variables cannot be set or altered by CONFIG SETENV. Other system Env$ variables will be added.
ENVIRONMENT INTERROGATION
ENV$("STATUS [ .sub-keyword ] ... " [, mat config$ [, search-arg] ...] )
ENV$ returns a string, or in the event that MAT CONFIG$ is provided, ENV$ redimensions and loads it. For a list of valid keywords issue a STATUS ENV command. If an array is specified, it may be followed by one or more case insensitive substrings which are regarded as restricting search arguments. For example:
ENV$("SERVER_PLATFORM")
returns “WINDOWS”
The following program displays all STATUS information that contains the word “file”:
00100 dim CONFIG$(1)*100 00120 let ENV$("STATUS",MAT CONFIG$,"file") 00140 print MAT CONFIG$
The above program produces the following output:
CHAINDFLT - Look for object files with source first. EDITOR C:\PROGRAM FILES\MILLS ENTERPRISE\MYEDITBR\MYEDITBR.EXE FILENAMES LOWER_CASE OPTION 23 is OFF - prevent data conversion errors from moving file position OPTION 25 is ON - make FILE$(0) be CON: if in windows OPTION 26 is OFF - suppress creation of .BAK files OPTION 29 is ON - save programs as .WB files OPTION 33 is 64 - locking position for large file support OPTION 49 is OFF - use relative path for spool file OPTION 51 is OFF - recover deleted records for all files SPOOLCMD prt.bat [SPOOLFILE] [COPIES] [PRINTER] Server File: :c:\wbserver.dat BR Config File: :C:\ADS\SYS\br.d\brconfig.sys Executable File: :C:\ADS\SYS\br.d\ brserver-430beta+q-Win32-DebugEfence-2011-03-20.exe Serial File: :C:\ADS\SYS\br.d\brserial.dat Workfile path: :c:\ads Open File # 0 :CON:
If you just want the options with the word file then use:
00100 dim CONFIG$(1)*100 00120 let ENV$("STATUS.CONFIG.OPTION",MAT CONFIG$,"file") 00140 print MAT CONFIG$
Which produces:
OPTION 23 is OFF - prevent data conversion errors from moving file position OPTION 25 is ON - make FILE$(0) be CON: if in windows OPTION 26 is OFF - suppress creation of .BAK files OPTION 29 is ON - save programs as .WB files OPTION 33 is 64 - locking position for large file support OPTION 49 is OFF - use relative path for spool file OPTION 51 is OFF - recover deleted records for all files
Note that while keywords are case insensitive, they must be correctly specified, whereas search arguments are more “friendly”. For a complete list of valid keywords, issue the command:
STATUS ENV -p
Some of the new keywords supported are:
ENV$("CLIENT_PLATFORM") is "WINDOWS" ENV$("CLIENT_PLATFORM.BR_BUILD_TYPE") is "DebugEfence" ENV$("CLIENT_PLATFORM.BR_BUILD_DATE") is "2011-05-12" ENV$("CLIENT_PLATFORM.BR_BITS") is "32" ENV$("CLIENT_PLATFORM.OS_BITS") is "64" ENV$("CLIENT_PLATFORM.OS_VERSION_NAME") is "Windows 7" ENV$("CLIENT_PLATFORM.OS_VERSION_NUMBER") is "6.1" ENV$("SERVER_PLATFORM") is "LINUX" ENV$("SERVER_PLATFORM.BR_BUILD_TYPE") is "DebugEfence" ENV$("SERVER_PLATFORM.BR_BUILD_DATE") is "2011-05-13" ENV$("SERVER_PLATFORM.BR_BITS") is "64" ENV$("SERVER_PLATFORM.OS_BITS") is "" ENV$("SERVER_PLATFORM.OS_VERSION_NAME") is "#36-Ubuntu SMP Thu Jun 3 20:38:33 UTC 2010" ENV$("SERVER_PLATFORM.OS_VERSION_NUMBER") is "2.6.32-22-server" BR_MODEL “CLIENT/SERVER” or “COMBINED”
Monitor Configuration Interrogation
ENV$("MONITOR1 | MONITOR2", MAT num-arrayname)
This redimensions num-arrayname to 4 elements and returns X (horizontal) and Y (vertical), of the upper left corner, and Width and Height in pixels of the current setting for either monitor 1 or monitor 2. Monitor 2 can be regarded as an extension of monitor 1 concerning the total video space.
Example Program (cut and paste into a text editor – then LOAD file SOURCE):
00010 let MONITORS$ = ENV$("monitor_count") 00020 let MONITORS = VAL(MONITORS$) 00030 print MONITORS 00040 for I = 1 to MONITORS 00050 let ENV$("monitor"&STR$(I), MAT TEST) 00060 for J = 1 to 4 00070 print TEST(J); 00080 next J 00090 print 00100 next I
Results for 2 monitors of differing sizes:
2 0 0 1280 1024 1280 0 1024 768