From:	CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP  4-AUG-1988 01:54
To:	ARISIA::EVERHART
Subj:	Saving and restoring terminal characteristics


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed,  3 AUG 88 08:29:23 PDT
Received: from CitHex.Caltech.Edu by KL.SRI.COM with TCP; Sun, 17 Jul 88 17:16:51 PDT
Date:    Sun, 17 Jul 88 10:49:46 PDT
From:     carl@CitHex.Caltech.Edu
Message-Id: <880717104946.16b@CitHex.Caltech.Edu>
Subject: Saving and restoring terminal characteristics
To:       info-vax@CitHex.Caltech.Edu
X-ST-Vmsmail-To: INFO-VAX

In order to be able to communicate conveniently with some computers  connected
to  CITHEX  via  terminal lines, I normally use some unusual terminal settings
(in particular, my VT220 is set to use 7 bits, space parity.  This corresponds
to  the  VMS  terminal  settings /DEVICE=VT200_Series/NOEIGHT_BIT.  I need the
/NOEIGHT_BIT for TPU to work.  Since the default for a  VT200_Series  terminal
is  /EIGHT_BIT,  setting  the  terminal  /DEVICE=VT200_Series  alone screws up
attempts to use TPU.  Unfortunately, this is exactly what a captive  procedure
I  frequently use on another computer on SPAN does.  As a result, I've written
two FORTRAN programs to save and restore terminal  characteristics,  and  sent
copies  of  them to the person who maintains the captive procedure.  Since the
programs are useful to me, I thought there might be some people out there  who
could  use them as well.  The programs are short and simple, and are therefore
undocumented.  They use the logical name TTY_MODE in the process logical  name
table to store terminal characteristics.  Since neither checks  to  make  sure
that  the  device TT is a terminal, if you use these from a command procedure,
they should be invoked with commands of the form:
	$ IF F$GETDVI("TT","DEVCLASS") .EQ. 66 THEN RUN SENSEMODE
and
	$ IF F$GETDVI("TT","DEVCLASS") .EQ. 66 THEN RUN SETMODE
Hope somebody finds this useful.

!----------------------------- Start SENSEMODE.FOR -----------------------------
! Sense terminal mode and store in logical name TTY_MODE
	PROGRAM SENSEMODE
	BYTE BUFFER(12)
	LOGICAL*2 CHAN,IOSB(4)
	LOGICAL*4 STAT, SYS$ASSIGN, SYS$QIOW

	INCLUDE '($IODEF)'

	STAT = SYS$ASSIGN('TT',CHAN,,)
	IF (IAND(STAT,7) .EQ.1) THEN
		STAT = SYS$QIOW(,%VAL(CHAN),%VAL(IO$_SENSEMODE),IOSB,,,
	1		BUFFER,%VAL(12),,,,)
		IF (IAND(STAT,7) .NE. 1) THEN
			TYPE 920, STAT
		ELSE IF (IAND(IOSB(1),7) .NE. 1) THEN
			TYPE 930, IOSB(1)
		ELSE
			STAT = LIB$SET_LOGICAL('TTY_MODE',%DESCR(BUFFER),,,)
				IF (IAND(STAT,7) .NE. 1) THEN
					TYPE 910, STAT
				ENDIF
		ENDIF
	ELSE
			TYPE 940, STAT
	ENDIF
910	FORMAT(' COULD NOT SET LOGICAL; STATUS = %X',Z8.8)
920	FORMAT(' COULD NOT QUEUE IO REQUEST; STATUS = %X',Z8.8)
930	FORMAT(' IO REQUEST FAILED; STATUS = %X',Z8.8)
940	FORMAT(' COULD NOT ASSIGN CHANNEL; STATUS = %X',Z8.8)
	END
!------------------------------ End SENSEMODE.FOR ------------------------------



!------------------------------ Start SETMODE.FOR ------------------------------
! Set terminal mode from logical name TTY_MODE
	PROGRAM SETMODE
	BYTE BUFFER(12)
	LOGICAL*2 CHAN,IOSB(4)
	LOGICAL*4 STAT, SYS$ASSIGN, SYS$QIOW

	INCLUDE '($IODEF)'

	STAT = SYS$ASSIGN('TT',CHAN,,)
	IF (IAND(STAT,7) .EQ.1) THEN
		STAT = LIB$SYS_TRNLOG('TTY_MODE',,%DESCR(BUFFER),,,)
		IF (IAND(STAT,7) .NE. 1) THEN
			TYPE 910, STAT
		ELSE
			STAT = SYS$QIOW(,%VAL(CHAN),%VAL(IO$_SETMODE),IOSB,,,
	1			BUFFER,%VAL(12),,,,)
			IF (IAND(STAT,7).NE.1) THEN
				TYPE 920, STAT
			ELSE IF (IAND(IOSB(1),7).NE.1) THEN
				TYPE 930, IOSB(1)
			ENDIF
		ENDIF
	ELSE
			TYPE 940, STAT
	ENDIF
910	FORMAT(' COULD NOT TRANSLATE LOGICAL; STATUS = %X',Z8.8)
920	FORMAT(' COULD NOT QUEUE IO REQUEST; STATUS = %X',Z8.8)
930	FORMAT(' IO REQUEST FAILED; STATUS = %X',Z8.8)
940	FORMAT(' COULD NOT ASSIGN CHANNEL; STATUS = %X',Z8.8)
	END
!------------------------------- End SETMODE.FOR -------------------------------

