From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP  7-SEP-1988 18:06
To:	ARISIA::EVERHART
Subj:	Re: set term characteristics


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue,  6 SEP 88 15:06:44 PDT
Received: from nrl.arpa (NRL3.ARPA) by KL.SRI.COM with TCP; Tue, 6 Sep 88 14:40:56 PDT
Date: 6 Sep 88 17:30:00 EDT
From: "NRL::HERMAN" <herman%nrl.decnet@nrl.arpa>
Subject: Re: set term characteristics
To: "info-vax" <info-vax@kl.sri.com>

>
>         I want to set terminal characteristics from within a
>     program (FORTRAN) without doing a spawn.  In particular I want
>     to toggle betwen type-ahead and no type-ahead.  I think chapter 8
>     of the I/O User's Reference Manual (Part I) discusses how to
>     do this, however I am new to VMS systems routines and can not
>     fathom the discussion.   Any help on how to interpret this
>     information would be appreciated.  Needless to say, an example
>     would be extremely usefull.
>
	I wish to thank Jeanie Larson, Selden E. Ball, Jr., Bill Sherman,
Ernest R. Bisson, and John Hascall for responding.  In summary, 

	1) Assign a channel to the terminal - the purpose of this is to
		get a channel number
	2) Get the current terminal characteristics via SYS$QIOW using function
		code IO$_SENSEMODE.
	3) Set new terminal characteristics via SYS$QIOW using function
		code IO$_SETMODE.

	As an example I am including a routine I wrote using the information 
sent me.  Since I am changing the type-ahead mode, I use the bit mask
TT$M_NOTYPEAHD, other bit masks can be found in Table 8.5 of the
I/O User's Reference Manual (Part I).  This routine works on VMS 4.6.

C===============================================================================
C
C Change type-ahead status of terminal.
C
C===============================================================================

	SUBROUTINE TypeAhead (typeAheadFlag)

	IMPLICIT INTEGER  (A-Z)

	LOGICAL		typeAheadFlag

	CHARACTER*3	deviceName /'TT:'/

	STRUCTURE /IOSB/
		INTEGER*2	status
		BYTE		transmitSpeed
		BYTE		receiveSpeed
		BYTE		CR_fillCount
		BYTE		LF_fillCount
		BYTE		paritys
		BYTE		%FILL(1)
	END STRUCTURE
 	RECORD /IOSB/ iosb

	STRUCTURE /P1/
		BYTE		class
		BYTE		type
		INTEGER*2	bufferSize
		INTEGER*4	termChars
	END STRUCTURE
	RECORD /P1/ p1
	
	INCLUDE '($TTDEF)'                  
	INCLUDE '($IODEF)'

C-------------------------------------------------------------------------------
C
C	Executable code begins.
C
C-------------------------------------------------------------------------------
!
! Assign a channel to the terminal, and get its channel number.
!
	status = SYS$ASSIGN (deviceName, channel,,)
	IF (.NOT. status) 
	1	CALL LIB$SIGNAL (%VAL(status)) ! signal if assign unsuccessful
!
! Get the terminal characteristics associated with this process.
!
	funcCode = IO$_SENSEMODE
	status = SYS$QIOW (,		     ! event flag - (will wait instead)
	1		%VAL(channel),	     ! terminal channel number
	1		%VAL(IO$_SENSEMODE), ! function code
	1		iosb,,,		     ! IO status block
	1		p1,
	1		8,,,,)	     	     ! length of p1 is 8

	IF (status) STATUS = iosb.status
	IF (.NOT. status) 
	1	CALL LIB$SIGNAL (%VAL(status)) ! signal if qio unsuccessful
!
! Change type ahead status in variable containing terminal characteristics.
!
	IF (typeAheadFlag) THEN 	! <<< clear no-type-ahead bit. >>>
	  p1.termChars = IAND (p1.termChars, NOT(TT$M_NOTYPEAHD)) 
 	ELSE 			! <<< set no-type-ahead bit. >>>
	  p1.termChars = IOR (p1.termChars, TT$M_NOTYPEAHDIO$_SENSEMODE) 
 	END IF                     
!
! Set the terminal characteristics to new typeahead status.
!
	funcCode = IO$_SETMODE
	status = SYS$QIOW (,		   ! event flag - (will wait instead)
	1		%VAL(channel),	   ! terminal channel number
	1		%VAL(IO$_SETMODE), ! function code
	1		iosb,,,		   ! IO status block
	1		p1,
	1		8,,,,)	   	   ! length of p1 is 8

	IF (status) STATUS = iosb.status
	IF (.NOT. status) 
	1	CALL LIB$SIGNAL (%VAL(status)) ! signal if qio unsuccessful
!
! Don't need this channel assignment anymore, so de-assign it.
!
	CALL SYS$DASSGN (channel)

	RETURN
	END


