From:	CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP  9-FEB-1988 22:36
To:	ARISIA::EVERHART
Subj:	RE: Dynamic prompts in VMS


Received: from UBVMS (ubvmsc.cc.Buffalo.EDU
Date: Mon, 25 Jan 88 15:36 EST
From: Rad <MASRAD@UBVMS.BITNET>
Subject: RE: Dynamic prompts in VMS
To: info-vax@kl.sri.COM
X-VMS-To: IN%"info-vax@kl.sri.com"

There have been some recent requests concerning prompts
in VMS that will show the current directory or other options.

About a year go now I created a program that does this function
quite well.  The program has since gained a fairly strong
following here with few bug reports. 

Here's the source:
----------------------------<cut here>---------------------------
$   save_verify = f$verify()
$   set noverify
$!      Customize prompt program. Gives current directory or time.
$!              by Geoff Cashman    masrad@ubvms
$!         Improvements to this program are welcome, and I sure wouldn't
$!	   mind hearing about them.  I only ask you leave my name up there.
$!	   It's my only claim to fame :-)
$!
$!      note: any customized commands used on your system for
$!	changing directories must be implemented here similar to the lines
$!	marked with the flag  !@@@
$!
$!      This program has controlling commands to change what is
$!      displayed in the prompt. Issueing these commands as regular
$!      vms commands will be interpreted by the program before
$!      being sent to VMS as a command. They are:
$!
$!	PTIME  - Changes the prompt to display the current time.
$!               time is updated after every carriage return.
$!
$!	PDIR   - (DEFAULT) Changes the prompt to display the current directory.
$!               directory is updated after every command issued to change
$!	         directories. Note: see note above: commands to change
$!		 directories are recognized by this program through 
$!		 hard-coding. 
$!
$!	Implementation: the program can be executed directly from your
$!		LOGIN.COM. Simply add the following line as the last
$!		executed line of your LOGIN.COM
$!		
$!			@<directory_specification>PROMPT.COM
$!
$!	Bugs/possible difficulties: The program has it's own stream
$!		identifier: ie, recall/all will not work. However,
$!		using up and down arrows to recall commands does. 
$!		Data lines from other DCL programs are ignored when
$!		run from this program as well, again because of stream
$!		identifiers. 
$!
$       n = 1
$	flagger = "dir"
$	ws :== "write sys$output"
$       ws "Type EXIT to leave this prompt"
$	goto prompter
$promptfirst:                ! set node and directory for prompt
$	flagger = command
$prompt:
$	if flagger .eqs. "PTIME" then goto timer
$	if flagger .eqs. "PDIR" then goto Prompter
$prompter:
$       node  = f$logical("sys$node")
$       nlen  = f$locate("::",node) - 1
$       ntemp = f$extract(1,nlen,node)
$       node  = f$extract(5,1,ntemp)
$       xdir = f$directory()
$       xdir = xdir + "."
$       xdir = xdir - "["
$       ddir = xdir
$shorten:               ! shorten the path list
$       adir = f$locate("]",ddir) + 2
$       bdir = f$locate(".",ddir) + 1
$       if adir .le. bdir then goto askcom
$       cdir = adir - bdir
$       ddir = f$extract(bdir,cdir,ddir)
$       goto shorten
$timer:
$	temp = f$time()
$	xtime = f$extract(12,5,temp)
$	option = xtime
$	goto askcom1
$askcom:                ! ask for DCL command to execute
$       xdir = ddir - "]."
$	option = xdir
$	goto askcom1
$askcom1:
$       flag = 0
$       set nocontrol=(y)
$       inquire/nopun command 'node'"{"'option'"}"'n'">"
$       if COMMAND .eqs. "" then goto askcom1
$       set control=(y)
$       cdcheck = f$extract(0,2,command)
$       setdefcheck = f$extract(0,7,command)
$       if CDCHECK .eqs. "SD" then flag = 1                !@@@
$       if CDCHECK .eqs. "CD" then flag = 1                !@@@
$       if SETDEFCHECK .eqs. "SET DEF" then flag = 1       !@@@
$	if COMMAND .eqs. "PTIME" then goto promptfirst
$	if COMMAND .eqs. "PDIR" then goto promptfirst
$       define/nolog/user_mode sys$input sys$command
$       on severe_error then goto increment
$       on error then goto increment
$       on warning then goto increment
$       set on
$       if save_verify then set verify
$       'command'
$	save_verify = f$verify()
$	set noverify
$increment:     !and loop
$       n = n + 1
$       if FLAG .eq. 1 then goto prompt
$	if FLAGGER .eqs. "PTIME" then goto timer
$       goto askcom1
----------------------------<cut here>---------------------------

There 'tis...Comments welcome and greatly appreciated.
Improvements too! Enjoy!

     - Rad (Geoffrey A. Cashman)

AT&T  : (716) 836-9694
Snail : 361 LaSalle street  Buffalo, NY 14215
BITnet: MASRAD@UBVMS (or ubvms(a,b,c, or d))
        MASDEV1@UBVM


-------

