C
C   SUBROUTINE TO HANDLE CRT
C
      SUBROUTINE NCRT(ZZ,N,NMAX)
      CHARACTER FOR*3(2)/'(A3','0)'/
      CHARACTER MSG*30,ZZ*3,AA*3,CON*3/'KON'/,END*3/'END'/
      REAL FIL6(2)
      INTEGER FCN,ITAG,IX,IY
      LOGICAL LTPEN
      COMMON/CCC/ITAG,LTPEN,IX,IY
      DATA FIL6(1),FIL6(2)/4HMSGS,4H SRC/
C  USE ONLY  LIGHTPEN LOOP IF N=99
      IF(N.EQ.99)GO TO 8
      CALL OPEN(1,FIL6)
      DO 1 I=1,1000
      READ(1,*)AA
      IF(AA.EQ.ZZ)GO TO 2
C   CODE NOT PRESENT GO TO 5
      IF(AA.EQ.CON)GO TO 5
    1 CONTINUE
    2 READ(1,*)NA
C   READ # OF LINES TO BE PUT ON CRT
      K1=60
      K=2
      IX=100
      IY=950
      IF(NA.GT.14)K1=35
      IF(NA.GT.14)K=1
      DO 3 I=1,NA
      ITAG=I
      READ(1,*)MSG
      CALL TEXT(2,ITAG,IX,IY,7,K,FOR,MSG)
      IY=IY-K1
    3 CONTINUE
C   IF CALLING PROG ONLY WANTS TO OUTPUT A MESSAGE GO TO 4
      IF(N.EQ.777)GO TO 4
    8 LTPEN=.FALSE.
    6 IF(LTPEN)GO TO 7
      GO TO 6
    7 IF(ITAG.GT.NMAX)GO TO 8
      N=ITAG
      CALL CLEAR(.TRUE.)
    4 CONTINUE
C   DELAY LOOP
      DO 20 I=1,500
   20 X=12*3.14159
      RETURN
C   IF SOUGHT CODE IS NOT IN FILE
    5 N=999
      RETURN
      END
