Env$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(Hopefully improved readability.)
Line 39: Line 39:
The [[STATUS]] command can display many types of internal settings. However there is one status secondary keyword that is very comprehensive and generates considerable output. That is "ENV". STATUS ENV outputs many of the attributes of the current session and the currently active version of BR. The ENV$ system function can also be used to retrieve this same data.  
The [[STATUS]] command can display many types of internal settings. However there is one status secondary keyword that is very comprehensive and generates considerable output. That is "ENV". STATUS ENV outputs many of the attributes of the current session and the currently active version of BR. The ENV$ system function can also be used to retrieve this same data.  


  ENV$("STATUS [ .sub-keyword ] ... " [, mat config$ [, search-arg] ...] )
  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 it with the results of a STATUS ENV command. The sub-keywords are the keywords produced by the STATUS ENV command. They are used to restrict the output to the specified keywords. For a list of valid keywords issue a STATUS ENV command.  
ENV$ returns a string, or in the event that a string array (e.g. MAT CONFIG$) is specified, ENV$ redimensions and loads it with the results of a STATUS ENV command. The sub-keywords are the keywords produced by the STATUS ENV command. They are used to restrict the output to the specified keywords. For a list of valid keywords issue a STATUS ENV command.  


Additionally ad hoc search arguments 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.  
Additionally 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.  


  ENV$("SERVER_PLATFORM")       
  ENV$("SERVER_PLATFORM")       

Revision as of 19:47, 20 May 2015

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")


Additionally, the following status command shows numerous BR environmental settings:

Status Env [ -P ]

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

  1. 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 are not accessible to 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.

BR SETTINGS ENVIRONMENT INTERROGATION

The STATUS command can display many types of internal settings. However there is one status secondary keyword that is very comprehensive and generates considerable output. That is "ENV". STATUS ENV outputs many of the attributes of the current session and the currently active version of BR. The ENV$ system function can also be used to retrieve this same 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 it with the results of a STATUS ENV command. The sub-keywords are the keywords produced by the STATUS ENV command. They are used to restrict the output to the specified keywords. For a list of valid keywords issue a STATUS ENV command.

Additionally 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.

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 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