Env$

From BR Wiki
Jump to navigation Jump to search
ENV$(<variable>)

The Env$(var$) returns the current value of the specified environment variable. To see a list of operating system environmental variables, enter the SET command with no parameters at the operating system prompt.

BR internal environmental values 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.

The Env$ function is used to retrieve local BR only environmental variable values (which were set with SetEnv).

Example:

got1$=env$("UserName")
got2$=env$("GUIMode")

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

For a complete list of possible ENV$ arguments issue the following command:

Status Env [ -P ]

Example:

ENV$("SERVER_PLATFORM")      

Returns “WINDOWS”

Technical Considerations

  1. Linux and MAC 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. This is a normal Linux/ MAC OS X requirement. Otherwise, the values of these variables are not accessible to BR.
  2. 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.
  3. The keyword CLIPBOARD retrieves the current contents of the Windows clipboard.
  4. BR_MODEL returns the model of Business Rules currently operating (COMBINED or CLIENT-SERVER).
  5. Also see Monitor Interrogation below.

BR SETTINGS ENVIRONMENT COMPREHENSIVE INTERROGATION

The ENV$("STATUS") function can be used to retrieve a broad range of program environment data. It returns the same type of data that the STATUS ENV command returns, except it populates a string array with the data.

ENV$("STATUS [ .sub-keyword ] ... " [, mat config$ ] [, "search-arg , ... " ] )

ENV$ returns a string, or in the event that a string array (e.g. MAT CONFIG$) is specified, ENV$ redimensions and loads the array with the results of a STATUS ENV command.

Use sub-keywords to restrict the output to specific values. For a list of valid keywords issue a STATUS ENV -P command.

Additionally, like the STATUS ENV command, an ad hoc space separated search arguments in a single string may be specified to filter the output. Each search argument provided is matched (case insensitive) against each output line and only matching lines are output. Individual space separated search words may be preceded with a tilde (~) to indicate exclusion of matching lines.

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$

This uses both the sub-keywords and the search string to filter the output 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 sub-keywords are case insensitive, they must be completely specified, whereas search strings are more “friendly”. For a complete list of valid keywords, issue the command:

STATUS ENV -p

Some of the 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>)

Either MONITOR1 or MONITOR2 redimensions num-arrayname to 4 elements and returns X (horizontal) and Y (vertical), of the upper left corner, and Width and Height in pixels ofthe 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