From:	CSBVAX::MRGATE!@KL.SRI.Com:sherman%v70nl.decnet@nusc.arpa@SMTP  3-SEP-1987 19:45
To:	EVERHART
Subj:	Datatrieve "shell" program providing definable keypad, command line recall, etc.

Received: from nusc.arpa by KL.SRI.COM with TCP; Thu 3 Sep 87 10:52:48-PDT
Date: 3 Sep 87 13:55:00 EDT
From: "V70NL::SHERMAN" <sherman%v70nl.decnet@nusc.arpa>
Subject: Datatrieve "shell" program providing definable keypad, command line recall, etc.
To: "info-vax" <info-vax@kl.sri.com>
Reply-To: "V70NL::SHERMAN" <sherman%v70nl.decnet@nusc.arpa>

The following program interfaces with Datatrieve's "Terminal Server", giving
you a definable keypad, 20 recallable command lines, and a few other little
goodies to boot.  I don't know if all this is old hat or not, but I thought
I'd throw in my 2 cents worth.

Bill,
Sherman@nusc.arpa

........................ Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-4.03 05-Aug-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by SHERMAN
$!      on Thursday 3-SEP-1987 13:48:00.34
$!
$! It contains the following 4 files:
$! AAAREADME.DOC BUILD.COM DTR.KEYPAD RDTR.FOR
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set (Output_File,b,o);
Position (Beginning_of(b));Loop x:=Erase_Character(1); Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;Move_Horizontal
(-Current_Offset);EndLoop;Move_Vertical(1);ExitIf Mark(None)=End_of(b)
EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="AAAREADME.DOC"
$ Check_Sum_is=2087325187
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X                   Recallable Datatrieve Version 1.1
X
XCongratulations, you are now the proud owner of recallable datatrieve.
XYes, now you won't drive yourself crazy while wishing that you could
Xretrieve a command you used only two lines ago - just like DCL lets you.
X
XThis package includes:
X        aaareadme.doc   if you can see this file, you're too close
X        build.com       command procedure to build rdtr.exe
X        rdtr.for        the source to recallable datatrieve
X        dtr.keypad      a sample key definition file
X
XThere are some other nice features that this program provided you with:
X
X1) Logical name DTR_NOCONTROL_Z
X
X    If defined, recallable datatrieve will ignore ^Z, instead of processing
X    a ^Z as exit.
X
X2) Logical name DTR_KEYPAD
X
X    If defined, recallable datatrieve will read key definitions from the
X    file to which this logical name points.  Each line of this file should
X    contain valid DEFINE/KEY commands.
X
X3) SHOW KEYPAD, UP, DOWN, and ACROSS commands
X
X    The SHOW KEYPAD command will show the currently defined keypad keys
X    and their equivalence strings.
X
X    The UP, DOWN, and ACROSS commands simplify movement within the CDD,
X
X    Command   Expansion
X    --------  -----------------------------------
X    UP        SET DICTIONARY -; SHOW DICTIONARY;
X    DOWN x    SET DICTIONARY .x; SHOW DICTIONARY;
X    ACROSS x  SET DICTIONARY -.x; SHOW DICTIONARY;
X
X    NOTE:  These commands are only processed interactively, and so will not
X           be available within procedures.
X
X                                                             Good luck,
X                                                             enjoy,
X                                                             Bill.
X
X+------------------------------------------------------------------------------+
X| ARPANET:  sherman@nusc.arpa           USPS:  Bill Sherman                    |
X| AT&T:     (203) 440-6210                     Naval Underwater Systems Center |
X|                                              MIS/OA/WP Group, Code 334       |
X|                                              Building 28, Room 200           |
X|                                              New London, CT  06320           |
X+------------------------------------------------------------------------------+
$ GoSub Convert_File
$ File_is="BUILD.COM"
$ Check_Sum_is=1060403558
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$!
X$! Precursory stuff
X$       set symbol/scope=noglobal
X$       wo = "write sys$output"
X$!
X$! Build it
X$       wo "Compiling"
X$       fortran/nolist/optimize/nodebug/nocheck rdtr
X$       wo "Linking (takes a little while)"
X$       link/nomap/nodebug/notrace/contiguous rdtr,sys$input/opt
Xsys$share:dtrshr/share, -
X!sys$share:dtrshrfm/share, -
Xdtr$library:termserve/library/include=(adt,edt,gui,hlp)
Xid="RDTR011"
X$!
X$! Cleanup
X$       delete rdtr.obj;*
X$       purge rdtr.exe
X$!
X$! Niceness
X$       wo "Defining logical DTR_KEYPAD to point to file DTR.KEYPAD"
X$       define/nolog dtr_keypad dtr.keypad
X$       wo "Ok, just run RDTR and have fun!"
$ GoSub Convert_File
$ File_is="DTR.KEYPAD"
$ Check_Sum_is=192595749
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X! state toggle keys
X
X        def/key pf1/set=gold ""
X
X! state DEFAULT
X
X        def/key help   "help;"/term
X        def/key pf2    "help;"/term
X        def/key kp1    "show all;"/term
X        def/key kp2    "show dictionary;"/term
X        def/key kp3    "show ready;"/term
X
X        def/key kp4    "fn$show_timer;"/term
X        def/key kp7    "fn$width(132); set columns_page=132;"/noecho/term
X        def/key kp8    "fn$spawn;"/term
X
X! state GOLD
X
X        def/key/if=gold help   "show keypad"/term
X        def/key/if=gold pf2    "show keypad"/term
X        def/key/if=gold kp1    "show domains;"/term
X        def/key/if=gold kp2    "show dictionaries;"/term
X        def/key/if=gold kp3    "show procedures;"/term
X
X        def/key/if=gold kp4    "fn$init_timer;"/term
X        def/key/if=gold kp7    "fn$width(80); set columns_page=80;"/noecho/term
$ GoSub Convert_File
$ File_is="RDTR.FOR"
$ Check_Sum_is=201354475
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
Xc
Xc    RECALLABLE_DTR
Xc
Xc    Written by:	
Xc
Xc 	???
Xc
Xc    Description:
Xc
Xc 	This programs provides a screen-management interface to Datatrieve
Xc	so that the up and down arrows can access the recall buffer.
Xc
Xc    Modification History:
Xc
Xc	03-AUG-1987, Bill Sherman
Xc	    Added code to handle SHOW KEYPAD command, as well as UP,
Xc	    DOWN, and ACROSS dictionary movement commands.
Xc
Xc 	02-AUG-1987, Bill Sherman
Xc	    Added code to check for the logical name DTR_NOCONTROL_Z.
Xc	    If this logical name exists, then ^Z will not EXIT from
Xc	    Datatrieve, but will simply be ignored.
Xc
Xc	    Also added code to handle personalized key definitions.
Xc	    The appropriate DEFINE/KEY command should be in the file
Xc	    pointed to by the logical name DTR_KEYPAD.
Xc
X	program recallable_dtr
X	implicit none
Xc
X	include '($smgdef)'
X	include 'dtr$library:dab.for'
Xc
X	integer*4 status, sys$trnlnm, dtr$dtr, process_line
X	integer*4 finis, keyboard, table, options, term, len
X	character line*255, long_msg_buff*132, long_aux_buff*132
Xc
X	external DTR$_EXIT, SS$_NORMAL
Xc
Xc  Check whether we should ignore ^Z, or treat it as an EXIT.
Xc
X	status = sys$trnlnm( , 'LNM$DCL_LOGICAL', 'DTR_NOCONTROL_Z',, )
X	if (status .eq. %loc(SS$_NORMAL)) then
X		finis = SMG$K_TRM_CTRLY	  ! something impossible...
X	else
X		finis = SMG$K_TRM_CTRLZ 
X	end if
Xc
Xc  Prepare screen management to handle our keyboard.
Xc
X	call smg$create_virtual_keyboard( keyboard )
X	call smg$create_key_table( table )
X	call smg$load_key_defs( table, 'DTR_KEYPAD',, 1)
Xc
Xc  Start up the Datatrieve server.
Xc
X	call dtr$init( dab, 100, long_msg_buff,
X     &		long_aux_buff, DTR$K_SEMI_COLON_OPT )
X	options = DTR$M_OPT_CONTROL_C + DTR$M_OPT_STARTUP +
X     &		  DTR$M_OPT_FOREIGN   + DTR$M_OPT_BANNER +
X     &		  DTR$M_OPT_CMD
X	status = dtr$dtr( dab, options )
Xc
Xc  Loop getting and doing of commands.
Xc
X	term = SMG$K_TRM_CR
Xc
X	do while (status .ne. %loc(DTR$_EXIT) .and. term .ne. finis)
X		call smg$read_composed_line( keyboard, table, line, 
X     &					long_msg_buff(1:DAB$W_MSG_LEN),
X     &					len,,,,,,, term )
X		status = process_line( dab, line, len, table, options )
X	end do
Xc
Xc  Close the Datatrieve server.
Xc
X	call dtr$finish( dab )
Xc
X	end
X
X	subroutine list_key_defs(table)
X	implicit none
Xc
X	integer*4 table
Xc
X	integer*4 status, smg$list_key_defs
X	integer*4 context
X	character key_name*6, if_state*10, equiv*40, state*10
Xc
X	external SS$_NORMAL
Xc
X	print 1
X1	format(1x, 'State', t13, 'Key', t20, 'Set-state', t31,  'Equivalence')
X	print 2
X2	format(1x, 10('-'), t13, 6('-'), t20, 10('-'), t31, 40('-'))
Xc
X	status = smg$list_key_defs( table, context, key_name, if_state,,
X     &				    equiv, state )
X	do while (status .eq. %loc(SS$_NORMAL))
X		print 3, if_state, key_name, state, equiv
X3		format(1x, a, t13, a, t20, a, t31, a)
X		status = smg$list_key_defs( table, context, key_name,
X     &					    if_state,, equiv, state )
X	end do
Xc
X	return
X	end
X
X	integer*4 function process_line(dab, line, len, table, options)
X	implicit none
Xc
X	integer*4 dab, len, table, options
X	character line*(*)
Xc
X	integer*4 dtr$dtr
X	integer*4 l
X	character verb*10, rest*80
X	character show*18/'; SHOW DICTIONARY;'/, set*15/'SET DICTIONARY '/
Xc
X	external SS$_NORMAL
Xc
X	l = index(line, ' ')
X	verb = line(1:l-1)
X	call str$upcase(verb, verb)
X	rest = line(l+1:)
X	call str$upcase(rest, rest)
X	l = len - l
Xc
X	if (verb .eq. 'SHOW' .and. rest .eq. 'KEYPAD') then
X		call list_key_defs( table )
X		process_line = %loc(SS$_NORMAL)
X	else
X		if (verb .eq. 'UP') then
X			call dtr$command( dab, set//'-'//show)
X		else if (verb .eq. 'DOWN') then
X			call dtr$command( dab, set//rest(1:l)//show)
X		else if (verb .eq. 'ACROSS' .or. verb .eq. 'ACR') then
X			call dtr$command( dab, set//'-.'//rest(1:l)//show)
X		else
X			call dtr$command( dab, line(1:len) )
X		end if
X		process_line = dtr$dtr( dab, options )
X	end if
Xc
X	return
X	end
$ GoSub Convert_File
$ Exit
------
