      SUBROUTINE MAIN
      LOGICAL*1 BUF(402)
      INTEGER FD, TT
      INTEGER OPEN
      INTEGER I, INPUT, J, MODE, NLINES
      INTEGER CTOI, GETARG, GETLIN, PRTNL, STMODE
      LOGICAL*1 TERML(4)
      LOGICAL*1 ST001Z(28)
      DATA TERML(1)/84/,TERML(2)/73/,TERML(3)/58/,TERML(4)/0/
      DATA NLINES /22/
      DATA INPUT /0/
      DATA ST001Z(1)/117/,ST001Z(2)/115/,ST001Z(3)/97/,ST001Z(4)/103/,ST
     *001Z(5)/101/,ST001Z(6)/58/,ST001Z(7)/32/,ST001Z(8)/32/,ST001Z(9)/9
     *9/,ST001Z(10)/114/,ST001Z(11)/116/,ST001Z(12)/32/,ST001Z(13)/91/,S
     *T001Z(14)/45/,ST001Z(15)/110/,ST001Z(16)/93/,ST001Z(17)/32/,ST001Z
     *(18)/91/,ST001Z(19)/102/,ST001Z(20)/105/,ST001Z(21)/108/,ST001Z(22
     *)/101/,ST001Z(23)/93/,ST001Z(24)/32/,ST001Z(25)/46/,ST001Z(26)/46/
     *,ST001Z(27)/46/,ST001Z(28)/0/
      CALL QUERY(ST001Z)
      TT = OPEN( TERML, 3)
      IF (.NOT.( TT .EQ. -3 ))GOTO 23000
      CALL CANT(TERML)
23000 CONTINUE
      MODE = STMODE( TT, 1)
      I = 1 
23002 IF (.NOT.(GETARG( I, BUF, 402) .NE. -1 ))GOTO 23004
      IF (.NOT.( BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0 ))GOTO 23005
      FD = 1
      GOTO 23006
23005 CONTINUE
      IF (.NOT.( BUF(1) .EQ. 45 ))GOTO 23007
      J = 2
      NLINES = MAX0( CTOI(BUF,J), 1)
      GOTO 23003
23007 CONTINUE
      FD = OPEN( BUF, 1)
      IF (.NOT.( FD .EQ. -3 ))GOTO 23009
      CALL CANT(BUF)
23009 CONTINUE
23008 CONTINUE
23006 CONTINUE
      INPUT = 1
      IF (.NOT.( PRTNL( FD, NLINES, TT) .EQ. -1 ))GOTO 23011
      GOTO 23004
23011 CONTINUE
      IF (.NOT.( FD .NE. 1 ))GOTO 23013
      CALL CLOSE(FD)
23013 CONTINUE
23003 I = I + 1 
      GOTO 23002
23004 CONTINUE
      IF (.NOT.( INPUT .EQ. 0 ))GOTO 23015
      CALL PRTNL( 1, NLINES, TT)
23015 CONTINUE
      RETURN
      END
      INTEGER FUNCTION PRTNL( FD, NL, TT)
      LOGICAL*1 BUF(402), C
      LOGICAL*1 GETCH
      INTEGER FD, TT
      INTEGER NL, PRMPT, MODE
      INTEGER GETLIN, GTMODE
      LOGICAL*1 RPSTR(25)
      LOGICAL*1 PSTR(1)
      DATA RPSTR(1)/13/,RPSTR(2)/10/,RPSTR(3)/91/,RPSTR(4)/80/,RPSTR(5)/
     *114/,RPSTR(6)/101/,RPSTR(7)/115/,RPSTR(8)/115/,RPSTR(9)/32/,RPSTR(
     *10)/83/,RPSTR(11)/80/,RPSTR(12)/65/,RPSTR(13)/67/,RPSTR(14)/69/,RP
     *STR(15)/32/,RPSTR(16)/102/,RPSTR(17)/111/,RPSTR(18)/114/,RPSTR(19)
     */32/,RPSTR(20)/109/,RPSTR(21)/111/,RPSTR(22)/114/,RPSTR(23)/101/,R
     *PSTR(24)/93/,RPSTR(25)/0/
      DATA PSTR(1)/0/
      DATA PRMPT /0/
      PRTNL = 0
      MODE = GTMODE(TT)
23017 CONTINUE
      IF (.NOT.( PRMPT .EQ. 1 ))GOTO 23020
      IF (.NOT.(MODE .NE. 0))GOTO 23022
      CALL PUTLIN(RPSTR, TT)
      PRTNL = GETCH(C, TT)
      IF (.NOT.(C .GE. 32))GOTO 23024
      CALL PUTCH(C, TT)
23024 CONTINUE
      GOTO 23023
23022 CONTINUE
      PRTNL = PROMPT(PSTR, BUF, TT)
      C = BUF(1)
23023 CONTINUE
      IF (.NOT.( PRTNL .EQ. 26 .OR. PRTNL .EQ. -1 ))GOTO 23026
      PRMPT = 0
      PRTNL=(-1)
      RETURN
23026 CONTINUE
      IF (.NOT.( C .EQ. 113 .OR. C .EQ. 81 ))GOTO 23028
      PRMPT = 0
      IF (.NOT.(MODE .NE. 0))GOTO 23030
      CALL PUTCH(13, TT)
23030 CONTINUE
      RETURN
23028 CONTINUE
      IF (.NOT.(MODE .NE. 0))GOTO 23032
      CALL PUTCH(13, TT)
23032 CONTINUE
23020 CONTINUE
      J = 1 
23034 IF (.NOT.(J .LE. NL ))GOTO 23036
      PRMPT = 1
      IF (.NOT.( GETLIN( BUF, FD) .EQ. -1 ))GOTO 23037
      RETURN
23037 CONTINUE
      CALL PUTLIN( BUF, 2)
23035 J = J + 1 
      GOTO 23034
23036 CONTINUE
23018 GOTO 23017
23019 CONTINUE
      RETURN
      END
