      SUBROUTINE MAIN
      INTEGER GETARG, GETLIN, OPEN
      LOGICAL*1 ARG1(40)
      LOGICAL*1 TXTFIL(40)
      LOGICAL*1 TCSFIL(40)
      LOGICAL*1 CLOWER
      INTEGER I, J
      CALL QUERY(30Husage:  admin -ifile file.tcs.)
      IF (.NOT.(GETARG(1, ARG1, 40) .EQ. -1 .OR. GETARG(2, TCSFIL, 40) .
     *EQ. -1))GOTO 23000
      CALL ERROR(31H? Usage:  admin -ifile file.tcs)
23000 CONTINUE
      IF (.NOT.(ARG1(1) .NE. 45))GOTO 23002
      CALL ERROR(14H- flag missing)
      GOTO 23003
23002 CONTINUE
      IF (.NOT.(CLOWER(ARG1(2)) .EQ. 105))GOTO 23004
      I = 3
      J = 1
23006 CONTINUE
      TXTFIL(J) = ARG1(I)
      IF (.NOT.(ARG1(I) .EQ. 0))GOTO 23009
      GOTO 23008
23009 CONTINUE
      I = I+1
      J = J+1
23007 GOTO 23006
23008 CONTINUE
      IF (.NOT.(J .EQ. 1))GOTO 23011
      CALL ERROR(22H-i... filename missing)
23011 CONTINUE
      CALL ADMIT(TXTFIL, TCSFIL)
      GOTO 23005
23004 CONTINUE
      CALL ERROR(12HInvalid flag)
23005 CONTINUE
23003 CONTINUE
      RETURN
      END
      SUBROUTINE ADMIT(TXTFIL, TCSFIL)
      LOGICAL*1 TXTFIL(40)
      LOGICAL*1 TCSFIL(40)
      LOGICAL*1 SCRFIL(40)
      INTEGER BMATCH, CREATE, GETLIN, OPEN, PROMPT, INDEXC
      LOGICAL*1 DATE( 10), TIME( 9)
      LOGICAL*1 INBUF(512)
      INTEGER FDTXT, FDSCR
      INTEGER CNT, NOW( 7), IND
      LOGICAL*1 SCT(4)
      DATA SCT(1)/83/,SCT(2)/67/,SCT(3)/84/,SCT(4)/0/
      FDTXT = OPEN(TXTFIL, 1)
      IF (.NOT.(FDTXT .EQ. -3))GOTO 23013
      CALL CANT(TXTFIL)
23013 CONTINUE
      CALL SCRATF(SCT, SCRFIL)
      FDSCR = CREATE(SCRFIL, 2)
      IF (.NOT.(FDSCR .EQ. -3))GOTO 23015
      CALL CANT(SCRFIL)
23015 CONTINUE
      CALL PUTLIN(4H%%s , FDSCR)
      CALL PUTLIN(5H0/0/0, FDSCR)
      CALL PUTCH(10, FDSCR)
      CALL PUTLIN(4H%%d , FDSCR)
      CALL PUTLIN(6HD 1.1 , FDSCR)
      CALL GETNOW(NOW)
      CALL FMTDAT( DATE, TIME, NOW, 1)
      CALL PUTLIN( DATE, FDSCR)
      CALL PUTCH(32, FDSCR)
      CALL PUTLIN( TIME, FDSCR)
      CALL PUTCH(32, FDSCR)
      CALL MAILID(INBUF)
      IND = INDEXC(INBUF, 32)
      IF (.NOT.(IND .GT. 0))GOTO 23017
      INBUF(IND) = 0
23017 CONTINUE
      CALL PUTLIN(INBUF, FDSCR)
      CALL PUTLIN(4H 1 0, FDSCR)
      CALL PUTCH(10, FDSCR)
      CALL PUTLIN(46HEnter general comments (end with a 'dot-line'), 3)
      CALL PUTCH(10, 3)
23019 CONTINUE
      CNT = PROMPT(2H> , INBUF, 1)
      IF (.NOT.(CNT .EQ. 0))GOTO 23022
      GOTO 23021
23022 CONTINUE
      IF (.NOT.((CNT .EQ. 2) .AND. (INBUF(1) .EQ. 46)))GOTO 23024
      GOTO 23021
23024 CONTINUE
      CALL PUTLIN(4H%%c , FDSCR)
      CALL PUTLIN(INBUF, FDSCR)
23020 GOTO 23019
23021 CONTINUE
      CALL PUTLIN(3H%%T, FDSCR)
      CALL PUTCH(10, FDSCR)
      CALL PUTLIN(4H%%I , FDSCR)
      CALL PUTLIN(1H1, FDSCR)
      CALL PUTCH(10, FDSCR)
23026 IF (.NOT.(GETLIN(INBUF, FDTXT) .NE. -1))GOTO 23027
      CALL PUTLIN(INBUF, FDSCR)
      GOTO 23026
23027 CONTINUE
      CALL PUTLIN(4H%%E , FDSCR)
      CALL PUTLIN(1H1, FDSCR)
      CALL PUTCH(10, FDSCR)
      CALL CLOSE(FDTXT)
      CALL CLOSE(FDSCR)
      CALL AMOVE(SCRFIL, TCSFIL)
      RETURN
      END
