sub get_input by ref (	string get_str by desc, prompt_str by desc,	&
			word out_len by ref )
!	Written by Michael W. Wheeler (mww@tntech.bitnet)
!	VAX Basic V3.1
!	Copyright (c) by Michael W. Wheeler, September 1987
!	This program is intended for Public Domain, and may not be sold or
!	marketed in any form without the permision and written consent
!	from the author Michael W. Wheeler.  I retain all copyrights to
!	this program, in either the original or modified forms, and no
!	violation, deletion, or change of the copyright notice is
!	allowed.  Futhermore, I will have no liability or responsibilty
!	to any user with respect to loss or damage caused directly or
!	indirectly by this program.

! Labels
!	none.

! Constants
%include "$smgtrmptr" %from %library "sys$library:basic$starlet.tlb"
external word constant	io$_readvblk, io$_readprompt

! Types
record iosblk
    word		io_status, xfr_len
    word		terminator, terminator_len
end record

record terminatorblk
    long		mask_size
    long		mask_location        
end record

! Variables
declare long		sys_status, terminator_mask(4%)
declare word		io_function, text_len
declare iosblk		iosb
declare terminatorblk	terminators
common (getbuf) string	text = 512%
common (io_w) word	chan, max_dir, cursor_len, start_row, start_col
common (io_l) long	term_table, col_len, num_cols, tt_cols, tt_rows
common (putstr) word	output_row

! Functions
external long function	sys$qiow

terminator_mask(1%) = X"FFFFFFFF"L	! All control keys          (31-0)
terminator_mask(2%) = X"80000000"L	! Question mark (?)         (63-32)
terminator_mask(3%) = X"00000000"L	! Nothing in ascii range    (95-64)
terminator_mask(4%) = X"80000000"L	! Delete                    (127-96)
terminators::mask_size = 16%
terminators::mask_location = loc(terminator_mask(1%))

io_function = io$_readvblk or io$_readprompt

sys_status = sys$qiow(	,		         ! Event flag		&
			chan by value, 	         ! I/O channel		&
			io_function by value,    ! Qio function		&
			iosb,		         ! I/O status block	&
			,			 ! AST routine		&
			, 			 ! AST routine param	&
			text by ref,	         ! Receive buffer	&
			len(text) by value,	 ! Max bytes to receive	&
			,			 ! Timout limit		&
			terminators by ref,      ! Terminator charaters	&
			prompt_str by ref,       ! Prompt string	&
			len(prompt_str) by value)! Length of prompt string
if (sys_status and 1%) = 0% then call lib$signal(sys_status by value) end if
if iosb::xfr_len = 0% then
    out_len = iosb::terminator_len
else
    out_len = iosb::xfr_len
end if

get_str = mid(text, 1%, out_len)

if term_table <> 0% then
    if (iosb::xfr_len <> 0%) or (get_str = "?") or 			&
		(prompt_str = "Press RETURN to continue ... ") then
	call set_cursor_abs( 1%, 1%, term_table, chan )
	call output( smg$k_erase_whole_display, term_table, chan )
	output_row = 0%
    end if
end if

subend
