      SUBROUTINE MAIN
      LOGICAL*1 NAME(36)
      INTEGER GETARG, OPEN, CTOI
      INTEGER FD, I, J
      INTEGER MAR1
      INTEGER MAR2
      INTEGER BMAR
      INTEGER DOHEAD
      INTEGER DOTAIL
      INTEGER PLEN
      LOGICAL*1 STDINP(15)
      LOGICAL*1 USESTR(30)
      LOGICAL*1 ST001Z(15)
      LOGICAL*1 ST002Z(26)
      COMMON /CPRINT/ MAR1, MAR2, BMAR, DOHEAD, DOTAIL, PLEN
      DATA STDINP(1)/83/,STDINP(2)/116/,STDINP(3)/97/,STDINP(4)/110/,STD
     *INP(5)/100/,STDINP(6)/97/,STDINP(7)/114/,STDINP(8)/100/,STDINP(9)/
     *32/,STDINP(10)/105/,STDINP(11)/110/,STDINP(12)/112/,STDINP(13)/117
     */,STDINP(14)/116/,STDINP(15)/0/
      DATA USESTR(1)/117/,USESTR(2)/115/,USESTR(3)/97/,USESTR(4)/103/,US
     *ESTR(5)/101/,USESTR(6)/58/,USESTR(7)/32/,USESTR(8)/32/,USESTR(9)/1
     *12/,USESTR(10)/114/,USESTR(11)/32/,USESTR(12)/91/,USESTR(13)/45/,U
     *SESTR(14)/108/,USESTR(15)/60/,USESTR(16)/110/,USESTR(17)/62/,USEST
     *R(18)/93/,USESTR(19)/32/,USESTR(20)/91/,USESTR(21)/102/,USESTR(22)
     */105/,USESTR(23)/108/,USESTR(24)/101/,USESTR(25)/93/,USESTR(26)/32
     */,USESTR(27)/46/,USESTR(28)/46/,USESTR(29)/46/,USESTR(30)/0/
      DATA ST001Z(1)/112/,ST001Z(2)/97/,ST001Z(3)/103/,ST001Z(4)/101/,ST
     *001Z(5)/32/,ST001Z(6)/116/,ST001Z(7)/111/,ST001Z(8)/111/,ST001Z(9)
     */32/,ST001Z(10)/115/,ST001Z(11)/109/,ST001Z(12)/97/,ST001Z(13)/108
     */,ST001Z(14)/108/,ST001Z(15)/0/
      DATA ST002Z(1)/105/,ST002Z(2)/103/,ST002Z(3)/110/,ST002Z(4)/111/,S
     *T002Z(5)/114/,ST002Z(6)/105/,ST002Z(7)/110/,ST002Z(8)/103/,ST002Z(
     *9)/32/,ST002Z(10)/105/,ST002Z(11)/110/,ST002Z(12)/118/,ST002Z(13)/
     *97/,ST002Z(14)/108/,ST002Z(15)/105/,ST002Z(16)/100/,ST002Z(17)/32/
     *,ST002Z(18)/97/,ST002Z(19)/114/,ST002Z(20)/103/,ST002Z(21)/117/,ST
     *002Z(22)/109/,ST002Z(23)/101/,ST002Z(24)/110/,ST002Z(25)/116/,ST00
     *2Z(26)/0/
      CALL QUERY(USESTR)
      MAR1 = 0
      MAR2 = 2
      BMAR = 0
      DOHEAD = 1
      PLEN = 60
      FD = -3
      I = 1
23000 IF (.NOT.(GETARG(I, NAME, 36) .NE. -1))GOTO 23002
      IF (.NOT.(NAME(1) .EQ. 45 .AND. NAME(2) .NE. 0))GOTO 23003
      IF (.NOT.(NAME(2) .EQ. 108 .OR. NAME(2) .EQ. 76))GOTO 23005
      J = 3
      PLEN = CTOI(NAME, J)
      IF (.NOT.((PLEN-MAR1-MAR2-BMAR-2) .LE. 0))GOTO 23007
      CALL ERROR (ST001Z)
23007 CONTINUE
      GOTO 23006
23005 CONTINUE
      CALL REMARK (ST002Z)
23006 CONTINUE
      GOTO 23004
23003 CONTINUE
      IF (.NOT.(NAME(1) .EQ. 45 .AND. NAME(2) .EQ. 0))GOTO 23009
      FD = 1
      CALL FPRINT (STDINP, 1)
      GOTO 23010
23009 CONTINUE
      FD = OPEN(NAME, 1)
      IF (.NOT.(FD .EQ. -3))GOTO 23011
      CALL CANT(NAME)
23011 CONTINUE
      CALL FPRINT(NAME, FD)
      CALL CLOSE(FD)
23010 CONTINUE
23004 CONTINUE
23001 I = I + 1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(FD .EQ.-3))GOTO 23013
      CALL FPRINT(STDINP, 1)
23013 CONTINUE
      RETURN
      END
      SUBROUTINE FPRINT(NAME, FD)
      LOGICAL*1 LINE(402), NAME(100), DATE(10), TIME(10)
      INTEGER GETLIN
      INTEGER FD, LINENO, PAGENO, NOW(7)
      INTEGER MAR1
      INTEGER MAR2
      INTEGER BMAR
      INTEGER DOHEAD
      INTEGER DOTAIL
      INTEGER PLEN
      COMMON /CPRINT/ MAR1, MAR2, BMAR, DOHEAD, DOTAIL, PLEN
      CALL GETNOW(NOW)
      CALL FMTDAT(DATE, TIME, NOW, 1)
      PAGENO = 0
      LINENO = 0
23015 IF (.NOT.(GETLIN(LINE, FD) .NE. -1))GOTO 23016
      IF (.NOT.(LINENO .EQ. 0))GOTO 23017
      PAGENO = PAGENO + 1
      IF (.NOT.(DOHEAD .EQ. 1))GOTO 23019
      CALL SKIP(MAR1)
      CALL HEAD(NAME, DATE, TIME, PAGENO)
      CALL SKIP(MAR2)
      LINENO = MAR1 + MAR2 + 1
23019 CONTINUE
23017 CONTINUE
      CALL PUTLIN(LINE, 2)
      LINENO = LINENO + 1
      IF (.NOT.(LINENO + BMAR .GE. PLEN))GOTO 23021
      CALL SKIP(BMAR)
      LINENO = 0
23021 CONTINUE
      GOTO 23015
23016 CONTINUE
      IF (.NOT.(LINENO .GT. 0))GOTO 23023
      CALL SKIP(PLEN-LINENO)
      CALL SKIP(BMAR)
23023 CONTINUE
      RETURN
      END
      SUBROUTINE HEAD(NAME, DATE, TIME, PAGENO)
      LOGICAL*1 NAME(100), DATE(100), TIME(100)
      INTEGER PAGENO
      LOGICAL*1 PAGE(10)
      LOGICAL*1 TWOBLK(3)
      DATA PAGE(1)/32/,PAGE(2)/32/,PAGE(3)/32/,PAGE(4)/80/,PAGE(5)/97/,P
     *AGE(6)/103/,PAGE(7)/101/,PAGE(8)/32/,PAGE(9)/32/,PAGE(10)/0/
      DATA TWOBLK(1)/32/,TWOBLK(2)/32/,TWOBLK(3)/0/
      CALL PUTCH(12, 2)
      CALL PUTLIN(NAME, 2)
      CALL PUTLIN(TWOBLK, 2)
      CALL PUTLIN(DATE, 2)
      CALL PUTCH(32, 2)
      CALL PUTLIN(TIME, 2)
      CALL PUTLIN(PAGE, 2)
      CALL PUTINT(PAGENO, 1,2)
      CALL PUTCH(10,2)
      RETURN
      END
      SUBROUTINE SKIP(N)
      INTEGER I, N
      I = 1
23025 IF (.NOT.(I .LE. N))GOTO 23027
      CALL PUTCH(10,2)
23026 I = I + 1
      GOTO 23025
23027 CONTINUE
      RETURN
      END
