      SUBROUTINE MAIN
      INTEGER GETARG, CTOI, OPEN, GETLIN, PRTNL
      INTEGER I, J, TT, NLINES, INPUT
      LOGICAL*1 BUF(400), TERML(40)
      DATA NLINES /22/
      DATA INPUT /0/
      CALL GTTY(TERML)
      TT = OPEN(TERML, 1)
      IF(.NOT.(TT .EQ. -3))GOTO 23000
      CALL CANT(TERML)
23000 CONTINUE
      I=1
23002 IF(.NOT.(GETARG(I,BUF,400).NE.-1))GOTO 23004
      IF(.NOT.(BUF(1) .EQ. 63 .AND. BUF(2) .EQ. 0))GOTO 23005
      CALL ERROR (25Husage:  crt [-n] [file ].)
      GOTO 23006
23005 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23007
      INT = 1
      GOTO 23008
23007 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 45))GOTO 23009
      J = 2
      NLINES = MAX0(CTOI(BUF,J), 1)
      GOTO 23003
23009 CONTINUE
      INT = OPEN(BUF,1)
      IF(.NOT.(INT .EQ. -3))GOTO 23011
      CALL CANT(BUF)
23011 CONTINUE
23010 CONTINUE
23008 CONTINUE
23006 CONTINUE
      INPUT = 1
      IF(.NOT.(PRTNL(INT, NLINES, TT) .EQ. -1))GOTO 23013
      GOTO 23004
23013 CONTINUE
      IF(.NOT.(INT .NE. 1))GOTO 23015
      CALL CLOSE(INT)
23015 CONTINUE
23003 I=I+1
      GOTO 23002
23004 CONTINUE
      IF(.NOT.(INPUT .EQ. 0))GOTO 23017
      CALL PRTNL(1, NLINES, TT)
23017 CONTINUE
      RETURN
      END
      INTEGER FUNCTION PRTNL(INT, NL, TT)
      INTEGER INT, NL, TT, PROMPT
      INTEGER GETLIN
      LOGICAL*1 BUF(400)
      DATA PROMPT /0/
      PRTNL = 0
23019 CONTINUE
      IF(.NOT.(PROMPT .EQ. 1))GOTO 23022
      PRTNL = GETLIN(BUF,TT)
      IF(.NOT.(PRTNL .EQ. -1))GOTO 23024
      PROMPT = 0
      RETURN
23024 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 113 .OR. BUF(1) .EQ. 81))GOTO 23026
      PROMPT = 0
      RETURN
23026 CONTINUE
23022 CONTINUE
      J=1
23028 IF(.NOT.(J.LE.NL))GOTO 23030
      PROMPT = 1
      IF(.NOT.(GETLIN(BUF, INT) .EQ. -1))GOTO 23031
      RETURN
23031 CONTINUE
      CALL PUTLIN(BUF, 2)
23029 J=J+1
      GOTO 23028
23030 CONTINUE
23020 GOTO 23019
23021 CONTINUE
      RETURN
      END
