      PROGRAM LIST66
      IMPLICIT INTEGER*2 (I-N)
      INTEGER*4 IYEAR,IMONTH,IDAY,IHOUR,IMIN,ISEC,IHUND,ICHAR
      INTEGER*4 ARGS,CMDLEN,ITEST,IBEG,IEND
      LOGICAL*4 THERE
C This program is designed to take an ASCII text file and list it to
C the printer with proper page breaks.
      CHARACTER TAIL*40,INSTRI*80,FNAME*40,FORMF*1
      FORMF=CHAR(12)
C Get the command tail and open the corresponding file
      CMDLEN=ARGS(TAIL)
      DO 2 I=1,40
      ITEST=ICHAR(TAIL(I:I))
2     IF(ITEST.LT.32) TAIL(I:I)=CHAR(ITEST+32)
      WRITE(9,5) TAIL
5     FORMAT(' Command Tail=',A40)
C Parse the tail string to eliminate leading blanks
      DO 10 IBEG=1,40
10    IF(TAIL(IBEG:IBEG).NE.' ') GO TO 50
12    WRITE(9,15) TAIL
15    FORMAT(1X,A40,'NOT A VALID FILE NAME')
      STOP
50    DO 52 IEND=IBEG+1,40
52    IF(TAIL(IEND:IEND).EQ.' ') GO TO 54
54    FNAME=TAIL(IBEG:IEND)
      WRITE(9,55) (FNAME(I:I),I=1,ITRIM(FNAME))
55    FORMAT(' File is:',80A1)
      INQUIRE(FILE=FNAME,EXIST=THERE)
      IF(.NOT.THERE) GO TO 12
      OPEN(UNIT=1,FILE=FNAME,STATUS='OLD',ACTION='READ')
      OPEN(UNIT=2,FILE='PRN:')
60    CALL DATE(IYEAR,IMONTH,IDAY)
      CALL TIMI(IHOUR,IMIN,ISEC)
      IPAGE=0
C Put out a page header
62    IPAGE=IPAGE+1
      WRITE(2,63) FNAME,IYEAR,IMONTH,IDAY,IHOUR,IMIN,ISEC,IPAGE
63    FORMAT(1X,A40,' Listed at ',I4,2('/',I2),2X,
     +2(I2,':'),I2,' Page ',I2/)
C Read 62 lines and print them out
      DO 80 NLIN=1,59
      READ(1,65,END=100) INSTRI
65    FORMAT(A80)
      WRITE(2,70) INSTRI
70    FORMAT(A80)
80    CONTINUE
C Space to the top of the next printer page
      WRITE(2,81) FORMF
81    FORMAT(A1)
      GO TO 62
C All done, end it
100   WRITE(2,81) FORMF
      STOP
      END
      SUBROUTINE TIMI(IHR,IMIN,ISEC)
C Returns hours, minutes, seconds from TIME library function
      INTEGER*4 IMIDN,IHR,IMIN,ISEC
C TIME is a library function that returns seconds past midnite.
C you may need to replace this routine if using other than AC Fortran
      CALL TIME(IMIDN)
      IHR=IMIDN/3600
      IMIN=(IMIDN-3600*IHR)/60
      ISEC=IMIDN-3600*IHR-60*IMIN
      RETURN
      END

