From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 27-APR-1993 21:31:19.45
To:	Info-VAX@KL.SRI.COM
CC:	
Subj:	Re: Recall within application program

In article <Bren-260493174511@smbmac.slac.stanford.edu>, Bren@ssrl01.slac.stanford.edu (Sean M. Brennan) writes:
> At the DCL level the RECALL (or uparrow) command remembers
> up to 20 prior commands.  In an application, using CLI$DCL_PARSE, it seems
> only one prior command is available with the uparrow.  I note, however,
> that certain programs (e.g. AUTHORIZE) can recall more than one command
> with the uparrow. Have I missed something obvious?  If not, has someone
> figured out how to emulate the uparrow (with editing) from
> within a program?  I can store prior commands within the program and
> emulate the RECALL command, but editing a prior command seems beyond my
> skill level.  I am programming in fortran, in case that matters.  Any
> suggestions would be welcome.

Hunter Goatley comes to the rescue again!  Enclosed is HG$GET_INPUT, a direct
replacement for LIB$GET_INPUT and allows for 20-line recall using the SMG
routines.  Everywhere you currently use LIB$GET_INPUT, change the call to
HG$GET_INPUT and you should be okay.  Worked for me!  I haven't tried it on
Alpha yet though...


	.TITLE	HG$GET_INPUT
	.IDENT	/01-003/
;++
;
;  Routine:	HG$GET_INPUT
;
;  Author:	Hunter Goatley, Western Kentucky University
;		goathunter@WKUVX1.BITNET
;
;  Date:	January 18, 1988
;
;  Functional Description:
;
;	This routine implements an easy-to-call interface to the SMG$ routines
;	to provide command recall when reading from SYS$INPUT.	It takes
;	the same arguments as LIB$GET_INPUT and may be substituted directly
;	in any call to LIB$GET_INPUT.
;
;	Example:
;
;		CALL LIB$GET_INPUT (buffer, prompt, buffer)
;			to
;		CALL HG$GET_INPUT (buffer, prompt, buffer)
;
;  Modified by:
;
;	01-003		Hunter Goatley		15-AUG-1989 14:46
;		Added .DSABL GLOBAL and .EXTRNs.
;
;	01-002		Hunter Goatley		20-JAN-1988 17:12
;		Modified to make last parameter optional.
;
;	01-001		Hunter Goatley		18-JAN-1988 07:24
;		Original version.
;
;--

;+
;
;	HG$GET_INPUT  get-str [,prompt-str] [,out-len]
;
;  Inputs:
;
;	4(AP)	- String which is read from SYS$INPUT.
;		  Address of string descriptor.   Write-only.
;	8(AP)	- Prompt message that is displayed.
;		  Address of string descriptor.  Read-only.
;	12(AP)	- Number of bytes written into @4(AP).
;		  Address of word.  Write-only.
;
;  Returns:
;
;	String in 4(AP) and status in R0.
;
;  Effects:
;
;	On first call, a key table and a virtual keyboard are created.
;
;-
	.ENABLE	SUPPRESSION
	.DSABL	GLOBAL

	.EXTRN	SMG$CREATE_KEY_TABLE
	.EXTRN	SMG$CREATE_VIRTUAL_KEYBOARD
	.EXTRN	SMG$READ_COMPOSED_LINE

	$RMSDEF					; RMS symbols
	$SSDEF					; System service status symbols
	$SMGDEF					; SMG$ symbols
	$SYIDEF					; Used to detect VMS V5

	.IF DEFINED SYI$_SMP_CPUS		;* VMS V5.x
	$$SMGMSGDEF				; SMG$ symbols
	.IFF					;* VMS V4.x
	.EXTRN	SMG$_EOF			; $$SMGMSGDEF does not exist
	.ENDC					;* End of version check

	.PSECT	_HG$GET_INPUT_DATA,NOEXE,WRT,LONG,SHR

KEY_TABLE_ID:	.LONG	0			; ID of key table created
KEYBOARD_ID:	.LONG	0			; ID of virtual keyboard created

	.PSECT	_HG$GET_INPUT_CODE,EXE,NOWRT,LONG,PIC,SHR
	.ENTRY	HG$GET_INPUT,^M<>

	TSTL	KEY_TABLE_ID			; Have we been called yet?
	BNEQU	10$				; Yes - skip initialization
	PUSHAL	KEY_TABLE_ID			; Create a key table
	CALLS	#1,G^SMG$CREATE_KEY_TABLE	; ...
	BLBC	R0,30$				; Return if error
	PUSHAL	KEYBOARD_ID			; Create a virtual keyboard
	CALLS	#1,G^SMG$CREATE_VIRTUAL_KEYBOARD
	BLBC	R0,30$				; ...

10$:	MOVL	#4,R0				; Assume 4 arguments
	CMPW	#3,(AP)				; If 3 arguments, push it, too
	BNEQU	20$				; Else, branch around it
	PUSHAW	@12(AP)				; Push all HG$GET_INPUT params
	INCL	R0				; Bump # of arguments
20$:	PUSHAQ	@8(AP)				; ... for the call to the SMG$
	PUSHAQ	@4(AP)				; ... routine
	PUSHAL	KEY_TABLE_ID			; Push the key table id
	PUSHAL	KEYBOARD_ID			; Push the keyboard id
	CALLS	R0,G^SMG$READ_COMPOSED_LINE	; Call SMG$ routine to read
	CMPL	#SMG$_EOF,R0			; Was ^Z entered?
	BNEQU	30$				; No - go on and return
	MOVL	#RMS$_EOF,R0			; Make status RMS$_EOF
30$:	RET					; Return to the caller

	.END

-- 
Ed Wilts, BC Systems, 4000 Seymour Place, Victoria, B.C., Canada, V8X 4S8
EWilts@Galaxy.Gov.BC.CA     Office:  (604) 389-3430   Fax: (604) 389-3412

