Eliminate piping STATUS into a file tp parse it!

More advanced topics discussed.

Moderators: Susan Smith, admin, Gabriel

Post Reply
bluesfannoz
Posts: 291
Joined: Fri Jun 19, 2009 9:01 am
Location: Lawrence, Kansas
Contact:

Eliminate piping STATUS into a file tp parse it!

Post by bluesfannoz »

I've written and example program of using the 4.3's ability to load the 'Status' information into and Array.

Why would you use this? No longer having to pipe output of STATUS into a file and read in. You can just load it into an array and parse it now!!

Code: Select all

00010 FRM_TEMP: FORM C 256
00030 DIM TEMP$*256
00050 LET TEMP$=RPT$("0",256)
00070 OPEN #6: "NAME=temp.ida,replace,RECL=256,KFNAME=temp.idx,KPS=1,KLN=5,shr",INTERNAL,OUTIN,KEYED
00090 Write #6,USING FRM_TEMP: TEMP$
00110 READ #6,USING FRM_TEMP,RESERVE: TEMP$
00130 OPEN #5: "name=temp.fil,replace",DISPLAY,OUTPUT
00150 DIM CONFIG$(1)*100
00170 Print "Files:"
00190 LET ENV$("STATUS.FILES",MAT CONFIG$)
00210 LET COUNTER=UDIM(CONFIG$)
00230 FOR CT=1 TO COUNTER
00250 LET CONFIG$(CT)=UPRC$(CONFIG$(CT))
00270 IF POS(CONFIG$(CT),"FILE #")>0 THEN PRINT CONFIG$(CT)
00290 IF POS(CONFIG$(CT),"RECL")>0 THEN PRINT CONFIG$(CT)
00310 IF POS(CONFIG$(CT),"LOCK")>0 THEN PRINT CONFIG$(CT)
00330 NEXT CT
00350 CLOSE #6: : CLOSE #5:
00370 Print "Program:"
00390 LET ENV$("STATUS.STACKS",MAT CONFIG$,"LINE") : PRINT MAT CONFIG$
00410 Print "Users:"
00430 LET ENV$("STATUS.USERS",MAT CONFIG$) : PRINT MAT CONFIG$
Attached is a screenshot of the output.


Here is more info on this from the 4.3 Release notes.
11) ENVIRONMENT INTERROGATION

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

ENV$ returns a string or, in the event 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.

e.g. 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 I just want the options with the word file then I would 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”
Attachments
ScreenShot063.jpg
ScreenShot063.jpg (98.97 KiB) Viewed 9466 times
Steve Koger
Computer Specialist
SEKESC-MACS Division
Post Reply