C
C MODULE 'QSCREEN'
C ================
C
C GRAPHICS ROUTINES FOR ANSI + T4014 TERMINALS
C ============================================
C
C Note: Uses the machine dependent routine TTSEND for output to the
C       terminal
C
C SUBROUTINE 'QGINIT'
C ===================
C
C INITIALISE GRAPHICS ROUTINES, (OPEN TEMPORARY FILE FOR POSTSCRIPT OPTION
C IF NEEDED)
C
      SUBROUTINE QGINIT (LUNPS, MSGERR, ITTYP, IUN, KUN)
C
C PARAMETERS
C
C       LUNPS (I)   LOGICAL UNIT FOR TEMPORARY FILE FOR USE IF
C                   POSTSCRIPT OUTPUT MAY BE REQUIRED; 0 IF NO
C                   POSTSCRIPT IS REQUIRED. (FILE WILL HAVE
C                   LOGICAL NAME 'QGTEMP')
C      MSGERR (I)   UNIT NUMBER FOR ERROR MESSAGES: 0 IF NONE
C                   REQUIRED.
C       ITTYP (I)   TERMINAL TYPE =0 'STANDARD' eg PERICOM/SELANAR 
C                                     ANSI/T4014 TERMINAL
C                                 =1 'XTERM' WINDOW
C         IUN (I)   LOGICAL UNIT NUMBER FOR THE TERMINAL INPUT
C         KUN (I)   LOGICAL UNIT NUMBER FOR THE TERMINAL OUTPUT
C
C SPECIFICATION STATEMENTS
C ------------------------
C
      CHARACTER*1 MODE, ESC, GS, US, FS, CR, FF, SUB
      COMMON /QQCHR/ MODE, ESC, GS, US, FS, CR, FF, SUB
      LOGICAL PSET
      COMMON /QQLAST/ PSET, KXH, KXL, KYH, KYL
      LOGICAL PSCRIP, PSON
      COMMON /QQPS/ PSCRIP, PSON, LUNP
      LOGICAL MAP
      COMMON /QQMAP/ MAP, XPMIN, XPMAX, YPMIN, YPMAX, 
     *               XMMIN, XMMAX, YMMIN, YMMAX, XSC, YSC
      COMMON /QQUNS/ LUNIN, LUNOUT
      CHARACTER*5 SAVSTR
      COMMON /QQSAV/ SAVSTR
      COMMON /QQSAVN/ NSAV
      COMMON /QQTTYP/ ITYP
      EXTERNAL QGFONT
      SAVE /QQCHR/,/QQLAST/,/QQPS/,/QQMAP/,/QQUNS/,/QQSAV/,/QQSAVN/
      SAVE /QQTTYP/
C
C CODE
C ----
C
      MODE = ' '
      ITYP = ITTYP
      PSET = .FALSE.
      MAP = .FALSE.
      ESC = CHAR(27)
      GS = CHAR(29)
      US = CHAR(31)
      FS = CHAR(28)
      CR = CHAR(13)
      FF = CHAR(12)
      SUB = CHAR(26)
      PSCRIP = .FALSE.
      PSON = .FALSE.
      LUNP = 0
      LUNIN = IUN
      LUNOUT = KUN
      NSAV = 0
      IF (LUNPS.LE.0) RETURN
C     OPEN (UNIT=LUNPS,FILE='QGTEMP',DISPOSE='DELETE',ERR=800)
      OPEN (UNIT=LUNPS,STATUS='SCRATCH',ERR=800)
      LUNP = LUNPS
      PSCRIP = .TRUE.
      RETURN
C
C ERROR
C
800   IF (MSGERR.GT.0) WRITE(MSGERR,801)
801   FORMAT(//,'**Unable to open temporary file for Postscript',
     *' option**',//)
      END
