C SUBROUTINE TTYINI
C COPYRIGHT (C) 1983 GLENN EVERHART
C PERMISSION IS GIVEN TO ANYONE TO USE, DISTRIBUTE, OR COPY THIS
C PROGRAM FREELY BUT NOT TO SELL IT COMMERICALLY.
	SUBROUTINE TTYINI
C PERFORM INITS ON UNIT 5. NORMALLY EITHER DO NOTHING OR
C REPLACE WITH SOMETHING THAT WORKS FOR YOUR SYSTEM. TYPICAL
C ACTIONS:
C  SET THE TERMINAL NOT TO WRAP AROUND
C  ATTACH TERMINAL SO TYPE-AHEAD WORKS
C  SET UP TERMINAL TO MUNGE AROUND THE ESCAPE SEQUENCES TO ALLOW
C  SPECIAL FUNCTION AND/OR ARROW KEYS TO WORK.
C VMS VERSION ... HIGHLY SYSTEM DEPENDENT...
	INTEGER*4 TTCHAN,STAT,SYS$ASSIGN,SYS$QIOW
	INTEGER*2 IOSB(4)
	LOGICAL*1 AKP(2)
	INTEGER*2 IOLVL,IOFG2
	COMMON/IOLVL/IOLVL,IOFG2
	INTEGER*4 MODEBF(3),IWRK,IW2
	INCLUDE '($IODEF)'
	INCLUDE '($TTDEF)'
	COMMON /TTCHN/TTCHAN
	DATA AKP/27,'='/
	STAT=SYS$ASSIGN('TT',TTCHAN,,)
	IW2=IO$_SENSEMODE
	STAT=SYS$QIOW(,%VAL(TTCHAN),%VAL(IW2),IOSB,,,MODEBF,%VAL(12),,,,)
	IW2=TTM$_WRAP
	IWRK=.NOT.(IW2)
	MODEBF(2)=MODEBF(2).AND.IWRK
	IW2=TT$M_ESCAPE
	IWRK=IW2
	MODEBF(2)=MODEBF(2).OR.IWRK
C TURN ON DESIRED CHARACTERISTICS (REALLY NEED THE ESCAPE CHARAC.
C BADLY...)
	IW2=IO$_SETMODE
	STAT=SYS$QIOW(,%VAL(TTCHAN),%VAL(IW2),IOSB,,,MODEBF,%VAL(12),,,,)
C NOW HAVING SET THE TERMINAL UP, GET BACK OUTTA HERE...
C FIRST SET AUXILIARY KEYPAD MODE UP ON UNIT 6 THOUGH.
	WRITE(6,2000)AKP
2000	FORMAT(2A1)
	RETURN
	END
C
C SUBROUTINE GETTTL(LINE)
C READ IN A TERMINAL LINE ON VAX...
C VMS VERSION. FOR STANDARD VANILLA VERSION COMMENT
C OUT ALL BUT THE FORTRAN READ AND UNCOMMENT THAT...
	SUBROUTINE GETTTL(LINE)
	LOGICAL*1 LINE(132)
C
C
C ****++++ VMS SPECIFIC BELOW
	INTEGER*4 TTCHAN,STAT,SYS$ASSIGN,SYS$QIOW
	INTEGER*2 IOSB(4)
	INTEGER*4 MODEBF(3),IWRK
	INCLUDE '($IODEF)'
	INCLUDE '($TTDEF)'
	COMMON /TTCHN/TTCHAN
	DO 1 N1=1,132
1	LINE(N1)=0
C NOTE TTCHAN IS SET UP IN TTYINI ABOVE
C CHANGE CODE TO READ-VIRTUAL-BLOCK
C	IWRK=IO$_TTYREADALL
	IWRK=IO$_READVBLK
	STAT=SYS$QIOW(,%VAL(TTCHAN),%VAL(IWRK),IOSB,,,LINE,%VAL(132),,,,)
C THAT OUGHT TO PULL EVERYTHING IN...
C SINCE WE ZERO THE BUFFER INITIALLY, FORGET THE COUNT. IT ONLY
C MATTERS IF BUFFER NEEDS TO BE CLEARED PAST IT...
C ****++++ VMS SPECIFIC ABOVE
C
C
C DUMMY CODE FOR FORTRAN READ...
C *********
C  **** HERE IS THE SECTION OF CODE YOU NEED FOR NON-VMS-SPECIFIC VERSION
C	READ(5,1000)LINE
C1000	FORMAT(132A1)
C *********
	RETURN
	END
