🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: vmsnet.sources
Article #35

DCL Menu v3.1 (1/1)

#35
From: Harry Flowers
Date: Wed, 19 Aug 1992 21:07
766 lines
33666 bytes
Submitted-by: flowers@memstvx1.memst.edu (Harry Flowers)
Posting-number: Volume 3, Issue 107
Archive-name: dcl_menu_2/part01
Supersedes: dcl_menu_2: Volume 3, Issue 53

This V3.1 of my VMS DCL MENU system.  It makes use of the !n%C,!%E,!%F FAO
directives, so probably won't run on some earlier versions of VMS (I'm not
sure when support for these directives was added).

New features since V3.0: Fixed bug with ever-growing prompt; would get
   caught in an error loop that you had to ^C out of if you stayed in
   it through many choices of options.

New features since V2.3:

 o Sub-menus within the same command file.  This was to address the problems
   with calling other menus and then wanting to exit all the way out.  A
   menu stop command was added in the last version, but that doesn't work
   well for captive accounts.  So, now all the menus (up to 256) may be in
   the same command procedure.  See the menu for more details.  [The passing
   of CAPTIVE in P1 is no longer needed for captive accounts or supported.]

 o Ability to pass options as parameters on the command line.  This will
   execute each option just as if they had been entered each time the
   "Select option:" prompt was given.  For example, in this example menu,
   issuing a "$ MENU S C Z C M" would cause the following to happen:
	S - selects the system usage menu (not displayed)
	C - performs a MONITOR CLUSTER for 2 minutes
	Z - returns to main menu
	C - selects the communications menu (not displayed at this time)
	M - performs a MAIL command
    When the user exits from MAIL, he would see the communications menu.
    Alternately, if "$ MENU S C Z C M Z" had been used, he would see the
    main menu after exiting MAIL.  If "$ MENU S C Z C M X" had been used,
    the programs would be run, but no menu would ever appear (neat, huh?)!

This menu contains example options to demonstrate how to set up a menu.
These options are not intended to work as-is (though a few, like MAIL,
should).
--
Harry Flowers                           Internet: FLOWERS@MEMSTVX1.MEMST.EDU
Memphis State University                & Bitnet: FLOWERS@MEMSTVX1

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On  5-AUG-1992 17:31:51.54   By user FLOWERS 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. MENU.COM;3
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X$!`09+-----------+            `7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`
V7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7
VE`7E`7E`7E`7E
X$!`09`7C *MENU.COM `7C            VMS Menu System                     `20
X$!`09+-----------+            Public Domain Version
X$`09GOSUB PRELIMINARIES !    Author: Harry Flowers                       `20
X$`09VERSION = "V3.1"    !    `7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7
VE`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E
V`7E`7E`7E`7E
X$!`09This is a DCL menu system.  Directions for setting up menus follow.
X$!`09A description of features for this system is to be found at the end of
X$!`09this procedure.  You should use file names of the form *_MENU.COM for
X$!`09these menus.  For example, CBI_MENU.COM might be a computer based
X$!`09instruction menu.
X$!`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7
VE`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E
V`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`
V7E
X$! Menu set-up directions:
X$!    New with V3 is sub-menus.  You can have up to 255 levels of sub-menus.
X$!    The top (or only) level is level 0.  The sub-menu levels are in the
X$!    one to two-hundred fifty-five (1-255).  The symbols for sub-menus have
X$!    "_l" in them where "l" is the sub-menu level.  Note that there is no
X$!    change for level 0, so this menu is compatible with V2 without changin
Vg
X$!    symbol names.
X$!
X$! 1) Enter the menu title(s) into MENU_TITLE(_n).
X$`09MENU_TITLE = "VMS Menu Options:"
X$`09MENU_TITLE_1 = "Communications"
X$`09MENU_TITLE_2 = "File and Directory Functions"
X$`09MENU_TITLE_3 = "Error Analysis and Reporting"
X$`09MENU_TITLE_4 = "System Monitoring and Usage"
X$!
X$! 2) Enter the menu options into MENU_OPTIONS(_n) separated by "/".
X$!    The items will appear on the menu in the order you specify.
X$!    You may use " " (space) options for separation lines or balancing.
X$`09MENU_OPTIONS = "C/M/E/S/X/L/ / "
X$`09MENU_OPTIONS_1 = "M/N/ /X/Z"
X$`09MENU_OPTIONS_2 = "P/S/D/ /X/Z"
X$`09MENU_OPTIONS_3 = "V/E/R/ /X/Z"
X$`09MENU_OPTIONS_4 = "U/A/S/P/C/ /X/Z"
X$!
X$! 3) Enter the menu password for options which you wish to require a
X$!    password into MENU_PASSWORD.  This is for particularly dangerous
X$!    options, and is intended to make you think twice, not for security.
X$`09MENU_PASSWORD = "CAUTION"
X$!
X$! 4) Enter the menu option descriptions in the form "OPT_n" where "n"
X$!    is the option.  Sub-menu options must be of the form "OPT_l_n",
X$!    where "l" is the menu level and "n" is the option.  The last line
X$!    of this section MUST be "END_MENU".
X$!    For example:`09$`09OPT_D = "Directory listing"
X$!
X$`09OPT_C = "Communications Menu"
X$`09OPT_1_M = "Mail"
X$`09OPT_1_N = "News"
X$`09OPT_1_X = "Exit the Menu"
X$`09OPT_1_Z = "Return to Main Menu"
X$!
X$`09OPT_M = "File Maintenance Menu"
X$`09OPT_2_P = "Purge files"
X$`09OPT_2_S = "C Swing"
X$`09OPT_2_D = "Disks % full"
X$`09OPT_2_X = "Exit the Menu"
X$`09OPT_2_Z = "Return to Main Menu"
X$!
X$`09OPT_E = "Error Menu"
X$`09OPT_3_V = "VAXsim"
X$`09OPT_3_E = "Show Errors"
X$`09OPT_3_R = "Report Errors"
X$`09OPT_3_X = "Exit the Menu"
X$`09OPT_3_Z = "Return to Main Menu"
X$!
X$`09OPT_S = "System Usage Menu"
X$`09OPT_4_U = "Users"
X$`09OPT_4_A = "Analyze System"
X$`09OPT_4_S = "Monitor System"
X$`09OPT_4_P = "Monitor Process"
X$`09OPT_4_C = "Monitor Cluster"
X$`09OPT_4_X = "Exit the Menu"
X$`09OPT_4_Z = "Return to Main Menu"
X$!
X$`09OPT_X = "Exit the Menu"
X$`09OPT_L = "Logout"
X$!
X$`09END_MENU`09! This line must end the menu descriptions
X$!
X$! 5) Enter the actions to be taken at these options.  You must start each
X$!    action with a label of the form "OPT_n:" where "n" is the option.
X$!    Sub-menu options must start with a label of the form "OPT_l_n" where
X$!    "l" is the menu level (1-255) and "n" is the option.  You then place
X$!    any lines to be executed, finished with $ END_OPT.  You may wish to
X$!    include ASK_CR to ask for a carriage return before proceeding.  Before
X$!    a particularly dangerous option, you may wish to include ASK_PASSWORD
X$!    to ask for the menu password before proceeding.  You may use MENU_EXIT
X$!    to exit this menu.
X$!    For example:`09$ OPT_P:
X$!`09`09`09$`09ASK_PASSWORD`09`09! Ask for a password
X$!`09`09`09$`09PURGE/LOG `5B...`5D*.*`09! Purge their files
X$!`09`09`09$`09ASK_CR`09`09`09! Let them see them
X$!`09`09`09$`09END_OPT`09`09`09! End of option
X$!
X$!    Also, to have an option change menu levels (currently the only method)
V,
X$!    set the symbol "MENU_LEVEL" to the desired level and issue the "NEW_ME
VNU"
X$!    command:`09`09$ OPT_N:
X$!`09`09`09$`09MENU_LEVEL = 1`09`09! Switch to sub-menu #1
X$!`09`09`09$`09NEW_MENU`09`09! Go setup the new menu
X$!`09`09`09$`09END_OPT`09`09`09! End of option
X$!`09`09`09$ OPT_1_N:
X$!`09`09`09$`09MENU_LEVEL = 0`09`09! Switch to main menu
X$!`09`09`09$`09NEW_MENU`09`09! Go setup the new menu
X$!`09`09`09$`09END_OPT`09`09`09! End of option
X$!
X$ OPT_C: ! "Communications Menu"
X$`09MENU_LEVEL = 1
X$`09NEW_MENU
X$`09END_OPT
X$!
X$ OPT_1_M: ! "Mail"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09MAIL
X$`09END_OPT
X$!
X$ OPT_1_N: ! "News"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09NEWS
X$`09END_OPT
X$!
X$ OPT_M: ! "File Maintenance Menu"
X$`09MENU_LEVEL = 2
X$`09NEW_MENU
X$`09END_OPT
X$!
X$ OPT_2_P: ! "Purge files"
X$`09@SYS$LOGIN:CLEAN.COM
X$`09END_OPT
X$!
X$ OPT_2_S: ! "C Swing"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09RUN MSUTIL:CSWING
X$`09END_OPT
X$!
X$ OPT_2_D: ! "Disks % full"
X$`09DISK
X$`09ASK_CR
X$`09END_OPT
X$!
X$ OPT_E: ! "Error Menu"
X$`09MENU_LEVEL = 3
X$`09NEW_MENU
X$`09END_OPT
X$!
X$ OPT_3_V: ! "VAXsim"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09VAXsim
X$`09END_OPT
X$!
X$ OPT_3_E: ! "Show Errors"
X$`09RUN SYS$SYSTEM:SYSMAN
XSET ENVIRONMENT/CLUSTER
XDO SHOW ERROR
XEXIT
X$`09ASK_CR
X$`09END_OPT
X$!
X$ OPT_3_R: ! "Report Errors"
X$`09@MYROOT:`5BMANAGER.MAINT`5DERRSUM.COM
X$`09TYPE/PAGE MYROOT:`5BMANAGER.MAINT`5DSYSERR.LIS
X$`09ASK_CR
X$`09END_OPT
X$!
X$ OPT_S: ! "System Usage Menu"
X$`09MENU_LEVEL = 4
X$`09NEW_MENU
X$`09END_OPT
X$!
X$ OPT_4_U: ! "Users"
X$`09SYSTAT
X$`09ASK_CR
X$`09END_OPT
X$!
X$ OPT_4_A: ! "Analyze System"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09ANALYZE/SYSTEM
X$`09END_OPT
X$!
X$ OPT_4_S: ! "Monitor System"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09MONITOR SYSTEM/END="+00:01:00"
X$`09END_OPT
X$!
X$ OPT_4_P: ! "Monitor Process"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09MONITOR PROCESS/TOPCPU/END="+00:01:00"
X$`09END_OPT
X$!
X$ OPT_4_C: ! "Monitor Cluster"
X$`09DEFINE/USER_MODE SYS$INPUT SYS$COMMAND
X$`09MONITOR CLUSTER/END="+00:02:00"
X$`09END_OPT
X$!
X$ OPT_L: ! "Logout"
X$`09LOGOUT
X$`09END_OPT
X$!
X$ OPT_X: ! "Exit the Menu"
X$ OPT_1_X:
X$ OPT_2_X:
X$ OPT_3_X:
X$ OPT_4_X:
X$`09MENU_EXIT
X$`09END_OPT
X$!
X$ OPT_1_Z: ! "Return to Main Menu"
X$ OPT_2_Z:
X$ OPT_3_Z:
X$ OPT_4_Z:
X$`09MENU_LEVEL = 0
X$`09NEW_MENU
X$`09END_OPT
X$!
X$!`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7
VE`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E
V`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`
V7E
X$! End of customizable menu features.  Do not modify anything past this poin
Vt.
X$!
X$!`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7
VE`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E
V`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`
V7E
X$!
X$ SETUP_MENU:
X$`09MENU_TEMP = F$FAO("!0UBMENU_OPTIONS!0%C!%E_''CUR_LEVEL'!%F",CUR_LEVEL)
X$`09MENU_OPTS = F$EDIT('MENU_TEMP',"COMPRESS,UPCASE")
X$`09MENU_TEMP = F$FAO("!0UBMENU_TITLE!0%C!%E_''CUR_LEVEL'!%F",CUR_LEVEL)
X$`09MENU_TITL = 'MENU_TEMP'
X$`09LEN_OPTIONS = F$LENGTH(MENU_OPTS)
X$`09NUM_OPTIONS = (LEN_OPTIONS + 1) / 2
X$`09NUM_LINES = (NUM_OPTIONS + 1) / 2
X$`09TOP_SCROLL = 8 + NUM_LINES`09! Top of scrolling region
X$`09BOT_SCROLL = TT_PAGE - 1`09! Bottom of scrolling region
X$`09IF TT_DECCRT THEN PROMPT_LINE = -
X`09`09F$FAO("!/!/") + "''ESC'`5B''TOP_SCROLL';''BOT_SCROLL'r" + PROMPT
X$!
X$!`09Check the options for descriptions.  We'll have to trust that
X$!`09there is a label for the option.  If there is also no label,
X$!`09the error "%DCL-W-USGOTO, target of GOTO not found" will occur.
X$`09XOPT = 0
X$`09COLUMN = 1
X$`09BASE_LINE = 8
X$`09SCREEN = ""
X$ SETUP_LOOP:
X$`09CUR_OPT = F$ELEMENT(XOPT,"/",MENU_OPTS)
X$`09OPT_NAME = F$FAO("!0UBOPT_!0%C!%E''CUR_LEVEL'_!%F!AS",CUR_LEVEL,CUR_OPT)
X$`09IF CUR_OPT .EQS. " " THEN 'OPT_NAME' = ""
X$`09IF F$TYPE('OPT_NAME') .NES. "STRING" THEN -
X`09'OPT_NAME' = "''REVERSE'ERROR: NO DESCRIPTION FOR OPTION!''ALL_OFF'"
X$`09SCREEN = SCREEN +-
X`09`09F$FAO(OPTLINE,BASE_LINE+XOPT,COLUMN,CUR_OPT,'OPT_NAME')
X$`09XOPT = XOPT + 1
X$`09IF XOPT .GE. NUM_OPTIONS THEN GOTO DISPLAY_MENU
X$`09IF XOPT .EQ. NUM_LINES
X$`09THEN`09COLUMN = 40
X$`09`09BASE_LINE = BASE_LINE - XOPT
X$`09ENDIF
X$`09GOTO SETUP_LOOP
X$!
X$ DISPLAY_MENU:`09!`09`09Display a Menu
X$!`09'F$VERIFY(0,0)' (Turns off verification.) In case `5EY or `5EC'd to her
Ve
X$`09ON CONTROL_Y THEN GOTO FINISH`09`09! Exit on `5EC or `5EY
X$`09IF P1 .NES. ""
X$`09THEN`09SELECTION = P1
X$`09`09P1 = P2
X$`09`09P2 = P3
X$`09`09P3 = P4
X$`09`09P4 = P5
X$`09`09P5 = P6
X$`09`09P6 = P7
X$`09`09P7 = P8
X$`09`09P8 = ""
X$`09`09GOTO GOT_SELECTION
X$`09ENDIF
X$!
X$!`09Format the date as MM/DD/YY
X$`09DATE = F$FAO("!2ZB/!2ZB/!2ZB",`09F$INTEGER(F$CVTIME(,,"MONTH")),-
X`09`09`09`09`09F$INTEGER(F$CVTIME(,,"DAY")),-
X`09`09`09F$INTEGER(F$EXTRACT(2,2,F$CVTIME(,,"YEAR"))))
X$!
X$!`09Display the top lines
X$`09IF TT_DECCRT
X$`09THEN`09WR CLEAR +-
X`09`09"''ESC'`5B1;30H''BOLD_ON'VMS Menu System ''VERSION'''ALL_OFF'"
X$`09`09WR SYSTEM_ID
X$`09`09WR F$FAO("User: !AS ''ESC'`5B3;65HDate: !AS",USERNAME,DATE)
X$`09`09WR "Dir : ''F$ENVIRONMENT("DEFAULT")'"
X$`09`09WR ""
X$`09`09WR BOLD_ON + MENU_TITL + ALL_OFF
X$`09ELSE`09WR F$FAO("!30* ") + "VMS Menu System ''VERSION'"
X$`09`09WR SYSTEM_ID
X$`09`09WR F$FAO("User: !AS",USERNAME)
X$`09`09WR F$FAO("Date: !AS",DATE)
X$`09`09WR "Dir : ''F$ENVIRONMENT("DEFAULT")'"
X$`09`09WR ""
X$`09`09WR MENU_TITL
X$`09ENDIF
X$`09WR/SYMBOL SCREEN
X$!
X$ GET_SELECTION:
X$!
X$!`09Format the time as HH:MM AM
X$`09AORP = "A"
X$`09HOUR = F$INTEGER(F$CVTIME(,,"HOUR"))
X$`09IF HOUR .GT. 11 THEN AORP = "P"
X$`09IF HOUR .GT. 12 THEN HOUR = HOUR - 12
X$`09TIME = F$FAO("!2ZB:!2ZB !ASM",HOUR,F$INTEGER(F$CVTIME(,,"MINUTE")),AORP)
X$!`09Show error message for last selection as well as the time
X$`09IF TT_DECCRT
X$`09THEN`09WR -
X`09"''ALL_OFF'''ESC'`5B''BOT_SCROLL';10H''ERRMSG'''ESC'`5B4;65HTime: ''TIME'
V"
X$`09ELSE`09WR F$FAO("!10* ") + ERRMSG
X$`09`09WR "Time: ''TIME'"
X$`09ENDIF
X$!
X$!`09Get the selection
X$`09READ/PROMPT="''PROMPT_LINE'"/TIME=180/ERROR=TIME_OUT/END=FINISH -
X`09`09SYS$COMMAND SELECTION
X$ GOT_SELECTION:
X$`09IF TT_DECCRT THEN WR ALL_OFF + RESET_SCROLL + CLEAR ! Reset screen
X$`09TIME_OUTS = 0`09`09`09`09`09! Clear timeouts
X$`09ERRMSG = ""`09`09`09`09`09! Clear error messages
X$`09ON CONTROL_Y THEN GOTO DISPLAY_MENU`09`09! Come back to menu
X$`09SELECTION = F$EDIT(SELECTION,"COMPRESS,TRIM,UPCASE") ! Clean up a bit
X$`09ONECHR = F$EXTRACT(0,1,SELECTION)`09`09! First character
X$`09IF ONECHR .EQS. ""  THEN GOTO NO_SELECTION`09! No option present
X$`09IF ONECHR .EQS. "$" THEN GOTO HANDLE_DCL`09! Want a DCL command
X$`09IF ONECHR .EQS. "?" THEN GOTO SHOW_HELP`09`09! Want some help
X$`09IF F$LOCATE(SELECTION,MENU_OPTS) .EQ. LEN_OPTIONS THEN GOTO NOT_VALID
X$`09OPT_NAME = F$FAO("!0UBOPT_!0%C!%E''CUR_LEVEL'_!%F!AS",CUR_LEVEL,ONECHR)
X$`09GOTO 'OPT_NAME'
X$!
X$ NOT_VALID:
X$`09ERRMSG = "%MENU-W-INVALID, ''SELECTION' is not a valid option"
X$`09GOTO DISPLAY_MENU
X$!
X$ TIME_OUT:
X$`09TIME_OUTS = TIME_OUTS + 1`09! Timeouts occur at 3 minute intervals
X$!`09WR F$FAO("''ALL_OFF'''ESC'`5B5;65H!''TIME_OUTS'*`B7")`09! for Debug
X$`09IF TIME_OUTS .LT. 15 THEN GOTO GET_SELECTION ! Less than 45 minutes
X$`09IF F$GETJPI("","PRCCNT") .GT. 0 THEN GOTO GET_SELECTION ! Subprocesses
X$`09IF TT_DECCRT THEN WR ALL_OFF + RESET_SCROLL + CLEAR ! Reset screen
X$`09LOGOUT`09`09`09`09! Since nobody's home, logout
X$!
X$ ASK_HIT_RETURN:
X$`09WR ""
X$`09IF TT_DECCRT
X$`09THEN`09READ/PROMPT=-
X`09"''ALL_OFF'''REVERSE'`5BPress RETURN to continue`5D''ALL_OFF' *** " -
X`09`09`09SYS$COMMAND DUMMY
X$`09ELSE`09READ/PROMPT="`5BPress RETURN to continue`5D *** " -
X`09`09`09SYS$COMMAND DUMMY
X$`09ENDIF
X$`09RETURN
X$!
X$ HANDLE_DCL:`09`09! Issue an arbitrary DCL command for the user
X$`09IF CAPTIVE THEN GOTO SORRY_CHARLIE
X$`09SELECTION = SELECTION - ONECHR
X$`09IF SELECTION .EQS. "" THEN INQUIRE SELECTION "DCL command"
X$`09IF SELECTION .EQS. "" THEN GOTO DISPLAY_MENU
X$`09IF SELECTION .EQS. "EX" .OR. -
X`09   SELECTION .EQS. "EXI" .OR. -
X`09   SELECTION .EQS. "EXIT" THEN GOTO FINISH`09! Want to exit
X$`09DEFINE/USER_MODE/NOLOG SYS$INPUT SYS$COMMAND`09! If they need to input
X$`09SET VERIFY=(PROCEDURE,IMAGE)`09`09! Show them everything
X$`09'SELECTION'
X$!`09'F$VERIFY(0,0)' (Turns off verification, even commented out.)
X$`09IF F$TRNLNM("SYS$INPUT",,,"USER",,"ACCESS_MODE") .EQS. "USER" THEN -
X`09`09DEASSIGN/USER_MODE SYS$INPUT ! In case they didn't run an image
X$`09ASK_CR
X$`09END_OPT
X$!
X$ SORRY_CHARLIE:`09! A captive account has tried to issue a DCL command
X$`09ERRMSG = "%MENU-W-CAPTIVE, Captive accounts cannot issue DCL commands"
X$`09GOTO DISPLAY_MENU
X$!
X$ NO_SELECTION:
X$`09IF TT_DECCRT
X$`09THEN`09ERRMSG = "%MENU-W-NOSEL, No selection entered; " +-
X`09`09`09"enter ''BOLD_ON'?''ALL_OFF' for help"
X$`09ELSE`09ERRMSG = "%MENU-W-NOSEL, No selection entered; " +-
X`09`09`09"enter ? for help"
X$`09ENDIF
X$`09GOTO DISPLAY_MENU
X$!
X$ SHOW_HELP:
X$`09TYPE/PAGE SYS$INPUT
X
X     This is the VMS Menu System.  It is implemented entirely in Digital
X     Command Language (DCL).
X
X     To execute an arbitrary DCL command, enter "$" followed by the command.
X     You may also just enter "$" and be prompted for your DCL command.  This
X     has the advantage of using the command recall buffer and defined keys.
X     You may not issue arbitrary DCL commands from captive accounts.
X
X     To get this help message, you enter "?".
X
X     Other commands are shown as options on your menu.  Just enter the lette
Vr
X     beside the option you wish.
X
X     You may exit this menu by holding the "Ctrl" key down and pressing "Z".
X$`09IF .NOT. CAPTIVE THEN WR -
X`09`09"     You may also exit by typing $EXIT or Ctrl C (`5EC)."
X$`09WR`09" "
X$`09WR`09"     Menu command file: ''F$ENVIRONMENT("PROCEDURE")'"
X$`09WR`09"     Current menu level: ''CUR_LEVEL'"
X$`09ASK_CR
X$`09END_OPT
X$!
X$ ASK_FOR_PASSWORD:`09`09! Ask the user for a password before proceeding
X$`09ON CONTROL_Y THEN GOTO PASSWORD_TRAP`09! Reset traps to turn terminal
X$`09ON ERROR THEN GOTO PASSWORD_TRAP`09! echo back before returning
X$`09SET TERMINAL/NOECHO`09`09`09! Don't display the password
X$`09READ/END=PASSWORD_TRAP/PROMPT="Menu password: " SYS$COMMAND PASSWORD
X$`09SET TERMINAL/ECHO`09`09`09! Turn terminal echo back on
X$`09ON CONTROL_Y THEN GOTO DISPLAY_MENU`09! Reset traps back to their
X$`09ON ERROR THEN GOTO ERROR_TRAP`09`09! original destinations
X$`09PASSWORD = F$EDIT(PASSWORD,"UPCASE,TRIM")`09! Entered password
X$`09MENU_PASSWORD = F$EDIT(MENU_PASSWORD,"UPCASE,TRIM") ! Menu password
X$`09IF PASSWORD .EQS. MENU_PASSWORD THEN RETURN`09! Valid password
X$`09ERRMSG = "%MENU-W-INVPASS, Invalid menu password; option aborted"
X$`09WR ERRMSG`09`09`09! Go ahead and show them the error
X$`09WAIT 00:00:03`09`09`09! Wait for them to read it here
X$`09END_OPT`09`09`09`09! Invalid password, return to menu
X$ PASSWORD_TRAP:
X$`09SET TERMINAL/ECHO`09`09`09! Turn terminal echo back on
X$`09ON ERROR THEN GOTO ERROR_TRAP`09`09! Reset error trap
X$`09END_OPT`09`09`09`09`09! Ctrl Y trap is reset at menu
X$!
X$ NEW_MENU:
X$`09IF F$TYPE(MENU_LEVEL) .NES. "INTEGER"
X$`09THEN`09ERRMSG = "Menu level change error"
X$`09`09END_OPT
X$`09ELSE`09CUR_LEVEL = 'MENU_LEVEL'
X$`09`09END_MENU
X$`09ENDIF
X$!
X$ PRELIMINARIES: ! This executes before almost anything else; basic setup
X$`09SAVE_IVERIFY = F$ENVIRONMENT("VERIFY_IMAGE")`09! Save & turn off
X$`09SAVE_PVERIFY = F$VERIFY(0,0)`09`09`09! verification
X$`09SAVE_MESSAGE = F$ENVIRONMENT("MESSAGE")`09`09! Save & turn on
X$`09SET MESSAGE/FACILITY/SEVERITY/IDENTIFICATION/TEXT ! error messages
X$`09CAPTIVE = F$ENVIRONMENT("CAPTIVE")`09`09! Are we captive?
X$`09IF F$MODE() .NES. "INTERACTIVE" THEN GOTO CLEANUP ! Only interactive
X$`09ON ERROR THEN GOTO ERROR_TRAP`09`09`09! Enable error trap
X$`09ON CONTROL_Y THEN GOTO FINISH`09`09`09! Enable `5EY and `5EC trap
X$`09ESC`5B0,8`5D = 27`09`09`09`09`09! ESC = ASCII 27
X$`09USERNAME = F$EDIT(F$GETJPI("","USERNAME"),"TRIM") ! Get our username
X$`09SYSTEM_ID = F$TRNLNM("PSM$ANNOUNCE")`09`09! Get system name
X$`09IF SYSTEM_ID .EQS. "" THEN -`09`09`09! If no PSM, use SYS
X`09SYSTEM_ID = F$TRNLNM("SYS$ANNOUNCE")`09`09! Get system name
X$`09SYSTEM_ID = F$EDIT(SYSTEM_ID,"COMPRESS,TRIM")`09! Clean it up a bit
X$`09CENTER = 40 - ((F$LENGTH(SYSTEM_ID)+1)/2)`09! Center the
X$`09CLEAR = ESC + "`5BH" + ESC + "`5BJ"`09`09`09! Clear screen
X$`09TT_PAGE = F$GETDVI("TT:","TT_PAGE")`09`09! Page length
X$`09RESET_SCROLL = ESC + "`5B1;''TT_PAGE'r"`09`09! Scrolling region
X$`09BOLD_ON = ESC + "`5B1m"`09`09`09`09! Bold
X$`09REVERSE = ESC + "`5B7m"`09`09`09`09! Reverse video
X$`09ALL_OFF = ESC + "`5B0m"`09`09`09`09! All attributes off
X$`09PLINE = TT_PAGE - 2`09`09`09`09! Prompt line
X$`09TT_DECCRT = F$GETDVI("TT:","TT_DECCRT")`09`09! Check for DECCRT
X$`09IF TT_DECCRT
X$`09THEN`09SYSTEM_ID = "''ESC'`5B2;''CENTER'H''SYSTEM_ID'"`09! system name
X$`09`09OPTLINE = "''ESC'`5B!UB;!UBH    ''BOLD_ON'!AS''ALL_OFF' !AS"
X$`09`09PROMPT = "''ALL_OFF'''ESC'`5B''PLINE';1H" +-
X`09`09`09"''BOLD_ON'Select Option:''ALL_OFF' "
X$`09ELSE`09SYSTEM_ID = F$FAO("!''CENTER'* ''SYSTEM_ID'")
X$`09`09OPTLINE = "!+!+    !AS  !AS!/"
X$`09`09PROMPT = F$FAO("!/Select Option: ")
X$`09ENDIF
X$`09TIME_OUTS = 0`09`09`09`09`09! Read timeouts
X$`09WR = "WRITE SYS$OUTPUT"`09`09`09`09! Shorthand write
X$`09ERRMSG = ""`09`09`09`09`09! No errors yet
X$`09CUR_LEVEL = 0`09`09`09`09`09! Current menu level
X$`09ASK_CR = "GOSUB ASK_HIT_RETURN"`09`09`09! Wait for CR
X$`09ASK_PASSWORD = "GOSUB ASK_FOR_PASSWORD"`09`09! Ask for a password
X$`09END_OPT = "GOTO DISPLAY_MENU"`09`09`09! Option end, no wait
X$`09END_MENU = "GOTO SETUP_MENU"`09`09`09! Menu end
X$`09MENU_EXIT = "GOTO FINISH"`09`09`09! MENU exit
X$`09MENU_STOP = "GOTO MENU_STOP"`09`09`09! STOP replaces EXIT
X$`09NEW_MENU = "GOTO NEW_MENU"`09`09`09! For new menu level
X$`09IF P1 .EQS. "CAPTIVE" THEN P1 = ""`09`09! V2 compatibility
X$`09RETURN`09`09`09`09`09`09! Return
X$!
X$ ERROR_TRAP:`09!'F$VERIFY(0,0)' (Turns off verification, even commented out
V.)
X$`09ERROR = $STATUS`09`09`09`09`09! Save error status
X$`09ON ERROR THEN GOTO ERROR_TRAP`09`09`09! Reset error trap
X$`09ERRMSG = F$MESSAGE(ERROR)`09`09`09! Get the message
X$`09ASK_CR`09`09`09`09`09`09! Let them see errors
X$`09END_OPT`09`09`09`09`09`09! Go to option end
X$!
X$ FINISH:`09!'F$VERIFY(0,0)' (Turns off verification, even commented out.)
X$`09IF TT_DECCRT THEN WR ALL_OFF + CLEAR + RESET_SCROLL ! Reset screen
X$ CLEANUP:
X$`09SET MESSAGE'SAVE_MESSAGE'`09`09`09! Restore messages
X$`09DUMMY = F$VERIFY(SAVE_PVERIFY,SAVE_IVERIFY)`09! Restore verification
X$`09EXIT`09`09`09`09`09`09! The End
X$ MENU_STOP:`09!'F$VERIFY(0,0)' (Turns off verification, even commented out.
V)
X$`09IF TT_DECCRT THEN WR ALL_OFF + CLEAR + RESET_SCROLL ! Reset screen
X$`09SET MESSAGE'SAVE_MESSAGE'`09`09`09! Restore messages
X$`09DUMMY = F$VERIFY(SAVE_PVERIFY,SAVE_IVERIFY)`09! Restore verification
X$`09STOP`09`09`09`09`09`09! The End
X$!
X$!------------------------ Modification History ----------------------------
V--
X$! V`09  Date`09`09   Author`09`09Description
X$!1.1`0902/01/89`09Harry Flowers`09Added message before exiting for
X$!`09`09`09`09`09terminals with less than VT100
X$!`09`09`09`09`09capabilities.
X$!1.1`0902/01/89`09Harry Flowers`09Allowed terminal width to be changed
X$!`09`09`09`09`09after entering the MENU system.
X$!`09`09`09`09`09(Previously always reset to state when
X$!`09`09`09`09`09the MENU system was entered.)
X$!1.2`0902/06/89`09Harry Flowers`09Added feature for chaining from other
X$!`09`09`09`09`09captive command procedures; if CAPTIVE
X$!`09`09`09`09`09is passed in parameter one, then the
X$!`09`09`09`09`09menu will exit instead of log out.
X$!1.2`0902/06/89`09Harry Flowers`09Updated help, directions, and features
X$!`09`09`09`09`09sections.
X$!1.2`0902/06/89`09Harry Flowers`09Added trim of leading and trialing
X$!`09`09`09`09`09spaces and tabs to SYS$ANNOUNCE for
X$!`09`09`09`09`09centering properly.
X$!1.3`0904/25/89`09Harry Flowers`09Added identification of the command
X$!`09`09`09`09`09procedure containing this menu to the
X$!`09`09`09`09`09help screen.
X$!1.4`0905/02/89`09Harry Flowers`09Added ASK_PASSWORD option to ask for
X$!`09`09`09`09`09a password for a particular option.
X$!`09`09`09`09`09MENU_PASSWORD was added to parameters.
X$!1.4`0905/03/89`09Harry Flowers`09Fixed bug with terminal type inquiry.
X$!1.5`0905/25/89`09Harry Flowers`09Made changes for public domain version
X$!`09`09`09`09`09and a bug fix for the terminal width
X$!`09`09`09`09`09(lost 132 column after added inquiry).
X$!1.6`0909/07/89`09Harry Flowers`09Changed an INQUIRE to a READ for new
X$!`09`09`09`09`09Captive account processing in VMS 5.2
X$!1.7`0911/16/89`09Harry Flowers`09Performance improvement; placed all
X$!`09`09`09`09`09screen options into a symbol to paint
X$!`09`09`09`09`09the screen faster.
X$!1.8`0904/11/90`09Harry Flowers`09Changed the DCL command option from a
X$!`09`09`09`09`09"@" to a "$"; seems more natural.
X$!1.9`0906/08/90`09Harry Flowers`09Changed header from using SYS$ANNOUNCE
X$!`09`09`09`09`09to PSM$ANNOUNCE.  PSM$ANNOUNCE is more
X$!`09`09`09`09`09likely to have the site id for unsecure
X$!`09`09`09`09`09systems (networked,etc.).  SYS$ANNOUNCE
X$!`09`09`09`09`09is usually something like "Unauthorized`20
X$!`09`09`09`09`09computer useage is illegal" nowdays.
X$!2.0`0909/04/90`09Harry Flowers`09Removed all of the terminal width
X$!`09`09`09`09`09handling.  Removing the SET TERM's
X$!`09`09`09`09`09greatly increases the performance.
X$!`09`09`09`09`09This is V2 because some may have come
X$!`09`09`09`09`09to depend on V1.x width paranoia, and
X$!`09`09`09`09`09it no longer resets the screen.  Also
X$!`09`09`09`09`09removed the SET TERM/INQUIRE; we'll
X$!`09`09`09`09`09just go with what already has been set.
X$!2.1`0901/18/91`09Harry Flowers`09Added " " options as separation lines
X$!`09`09`09`09`09for grouping and balancing options.
X$!2.2`0910/09/91`09Harry Flowers`09Added support for variable page length,
X$!`09`09`09`09`09due to a report of the problem with
X$!`09`09`09`09`09RESET_SCROLL and suggested change from
X$!`09`09`09`09`09Curtis Sardeson.
X$!2.3`0902/06/92`09Harry Flowers`09Added support for non-ANSI terminals
X$!`09`09`09`09`09and a way to exit out of all menus.
X$!`09`09`09`09`09Thanks to Kent Brodie for his help.
X$!3.0`0906/11/92`09Harry Flowers`09Added internal sub-menus.  Removed
X$!`09`09`09`09`09the coding for P1 and CAPTIVE that was
X$!`09`09`09`09`09added in V1.2 because captive accounts
X$!`09`09`09`09`09are now more secure (no DCL access).
X$!`09`09`09`09`09Menu options may now be passed to the
X$!`09`09`09`09`09menu in P1 - P8 (up to 8 options).
X$!3.1`0908/05/92`09Harry Flowers`09Fixed problem with ever-growing prompt.
X$!`09`09`09`09`09Thanks to Jasper Rees for reporting the
X$!`09`09`09`09`09problem (it caused TKNOVF errors).
X$!`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7
VE`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E
V`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`
V7E
X$! Features:
X$!    o`09One-file menu - this command file is the only one which is needed.
X$!`09It is very easy to modify the menu options for anyone with a basic
X$!`09knowledge of DCL command procedures.  There is a small amount of
X$!`09error checking for consistent menu setup (for descriptions).
X$!    o`09Arbitrary DCL commands - any non-captive user may issue arbitrary
V DCL
X$!`09commands from the command line.  This can happen in one of two ways:
X$!`091) Precede the command by an "$", or 2) Enter an "$" and be prompted
X$!`09for the DCL command.  One advantage of method #2 is that INQUIRE is
X$!`09used instead of READ, so the full command recall handling is available.
X$!    o`09Automatic logout - users are logged out after 45 minutes of inacti
Vvity.
X$!`09The READ used has a 3 minute timeout.  When the timeout occurs, the
X$!`09time on the menu is updated as well as the timeout counter.  After 15
X$!`09timeouts (45 minutes), the process is logged out unless it has a
X$!`09subprocess which might be active.  NOTE: Broadcast messages seem to
X$!`09re-start the time for the read timeout.  This extends the time a
X$!`09process waits before automatically logging out.
X$!    o`09Captive account handling - captive accounts are handled specially.
X$!`09Captive accounts are not allowed to issue arbitrary DCL commands with
X$!`09the "$" on the command line.  A`09captive account is one authorized wit
Vh
X$!`09the Captive flag set in the user authorization file (with AUTHORIZE).
X$!`09It is assumed that Ctrl/Y has been disabled for captive accounts, and
X$!`09that they have not been allowed to get to a VMS prompt.  Normally,
X$!`09the menu would be called directly from the account's login command
X$!`09procedure.
X$!    o`09Error message display - if a fatal error occurs during the executi
Von
X$!`09of an option, the menu waits for a carriage return allowing the user
X$!`09to see the error.  It is also displayed below the input line on the
X$!`09menu screen.
X$!    o`09Scrolling region for broadcast messages - while the menu is on the
X$!`09screen, the scrolling region is re-defined to be after the last line
X$!`09of options.  This causes broadcast messages to scroll in this window
X$!`09and not mess up the menu display.
X$!    o`09"Self" customized - the second line of the display is whatever the
X$!`09system manager has defined for PSM$ANNOUNCE, which is used by the
X$!`09print symbiont on printouts.  If PSM$ANNOUNCE is not defined, then
X$!`09SYS$ANNOUNCE is used.  SYS$ANNOUNCE is the announcement message a
X$!`09user gets before the "Username:" prompt when logging in.  These will
X$!`09generally have the name of the installation, and in a VAXcluster
X$!`09environment, the system node name as well.  This can easily be changed
X$!`09by defining a process logical PSM$ANNOUNCE (which will not effect the
X$!`09system definition) if you are unhappy with the contents`09of PSM$ANNOUN
VCE
X$!`09or SYS$ANNOUNCE.  For example: $ DEFINE PSM$ANNOUNCE "My Own Computer"
X$!    o Option passing - up to eight (8) options can be passed to the menu o
Vn
X$!`09the command line.  They will execute one after the other.  Note that
X$!`09passing "CAPTIVE" as P1 is obsolete, and all parameters will be ignored
V.
X$!    o Sub-menus - up to 256 different menu screens are possible from withi
Vn
X$!`09the same menu (but not really feasible).  The main menu (level 0) and
X$!`09up to 255 sub-menus may be defined.  This allows multiple menus without
X$!`09having to chain to another command file.
$ CALL UNPACK MENU.COM;3 1717585193
$ v=f$verify(v)
$ EXIT
Technical Details
Message-ID: <7838377@MVB.SAIC.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!dog.ee.lbl.gov!network.ucsd.edu!mvb.saic.com!vmsnet-sources

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!dog.ee.lbl.gov!network.ucsd.edu!mvb.saic.com!vmsnet-sources
From: flowers@memstvx1.memst.edu (Harry Flowers)
Newsgroups: vmsnet.sources
Subject: DCL Menu v3.1 (1/1)
Message-ID: <7838377@MVB.SAIC.COM>
Date: Wed, 19 Aug 1992 21:07:08 GMT
Organization: Memphis State University
Lines: 766
Approved: Mark.Berryman@Mvb.Saic.Com