sub output( long req_code, term_table_addr, word chan )
!	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
external long constant		msg_getdata, msg_notavail
external word constant		io$_writevblk

! Types
!	none.

! Variables
declare long			sys_status, ret_len
common (buf) string		data_buffer = 20 ! buffer to hold terminal data

! Procedures
!	none.

! Functions
external integer function	smg$get_term_data, sys$qiow

! Get the requested sequence.

sys_status = SMG$GET_TERM_DATA(	term_table_addr			! addr of terminal definition &
				,req_code			! request code	&
				,20%				! max buffer length &
				,ret_len			! bytes returned &
				,data_buffer by ref)		! buffer for sequence

if (sys_status and 1%) = 0% then
    call lib$signal( msg_getdata by value, 1% by value, "requested" by desc )
    call sys$exit( sys_status by value )
end if

if ret_len = 0% then
    call lib$signal( msg_notavail by value, 1% by value, "requested" by desc )
    exit sub
end if

! Output the sequence to the terminal.

sys_status = SYS$QIOW(  ,chan by value		! channel number &
			,io$_writevblk by value	! function code value &
			,,,			! no iosb, ast routine, or argument &
			,data_buffer by ref	! buffer to output &
			,ret_len by value	! bytes in buffer &
			,,,,)			! null arguments

if (sys_status and 1%) = 0% then
    call sys$exit( sys_status by value )
end if

!print #2%, mid(data_buffer, 1%, ret_len);

subend
