      SUBROUTINE MAIN
      LOGICAL*1 BUF(400), TABC
      INTEGER FROM(10), TO(10)
      LOGICAL*1 OFMT(400)
      INTEGER I, J, K, N, NFLDS, LEN, FD, TFLAG, FILES
      INTEGER GETARG, GETLIN, OPEN, DOFLDS, GETFMT
      DATA TABC /9/, TFLAG /1/, NFLDS /10/
      I = 1
      IF(.NOT.(GETARG(1, BUF, 400) .EQ. -1))GOTO 23000
      CALL USAGE
      GOTO 23001
23000 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 63 .AND. BUF(2) .EQ. 0))GOTO 23002
      CALL USAGE
23002 CONTINUE
23001 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 116))GOTO 23004
      IF(.NOT.(BUF(3) .NE. 0))GOTO 23006
      TABC = BUF(3)
23006 CONTINUE
      I = 2
      GOTO 23005
23004 CONTINUE
      IF(.NOT.(BUF(1) .GE. 48 .AND. BUF(1) .LE. 57))GOTO 23008
      NFLDS = DOFLDS(BUF, FROM, TO, 10)
      IF(.NOT.(NFLDS .EQ. -3))GOTO 23010
      CALL ERROR (28Hillegal field specification.)
23010 CONTINUE
      TFLAG = 0
      I = 2
23008 CONTINUE
23005 CONTINUE
      IF(.NOT.(GETARG(I, BUF, 400) .EQ. -1))GOTO 23012
      CALL USAGE
23012 CONTINUE
      JUNK = GETFMT(BUF, OFMT)
      FILES = 0
      I=I+1
23014 CONTINUE
      IF(.NOT.(GETARG(I, BUF, 400) .EQ. -1))GOTO 23017
      IF(.NOT.(FILES .EQ. 1))GOTO 23019
      GOTO 23016
23019 CONTINUE
      FD = 1
      GOTO 23018
23017 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23021
      FD = 1
      GOTO 23022
23021 CONTINUE
      FD = OPEN(BUF, 1)
23022 CONTINUE
23018 CONTINUE
      FILES = 1
      IF(.NOT.(FD .EQ. -3))GOTO 23023
      CALL CANT(BUF)
23023 CONTINUE
      LEN = GETLIN(BUF, FD)
23025 IF(.NOT.(LEN .NE. -1))GOTO 23026
      IF(.NOT.(TFLAG .EQ. 1))GOTO 23027
      CALL DOTABS(BUF, TABC, FROM, TO, NFLDS)
23027 CONTINUE
      J = 1
23029 IF(.NOT.(OFMT(J) .NE. 0))GOTO 23031
      IF(.NOT.(OFMT(J) .EQ. -1))GOTO 23032
      N = OFMT(J+1)
      K = FROM(N)
23034 IF(.NOT.(K .LE. TO(N) .AND. K .LT. LEN))GOTO 23036
      CALL PUTCH(BUF(K), 2)
23035 K = K + 1
      GOTO 23034
23036 CONTINUE
      J = J + 1
      GOTO 23033
23032 CONTINUE
      CALL PUTCH(OFMT(J), 2)
23033 CONTINUE
23030 J = J + 1
      GOTO 23029
23031 CONTINUE
      CALL PUTCH(10, 2)
      LEN = GETLIN(BUF, FD)
      GOTO 23025
23026 CONTINUE
      IF(.NOT.(FD .NE. 1))GOTO 23037
      CALL CLOSE(FD)
23037 CONTINUE
23015 I=I+1
      GOTO 23014
23016 CONTINUE
      RETURN
      END
      INTEGER FUNCTION DOFLDS(BUF, FROM, TO, MAXSIZ)
      LOGICAL*1 BUF(100)
      INTEGER FROM(100), TO(100), MAXSIZ
      INTEGER I, N
      INTEGER CTOI
      N = 1
      FROM(1) = 1
      TO(1) = HUGE
      I = 1
23039 IF(.NOT.(BUF(I) .NE. 0))GOTO 23041
      N = N + 1
      IF(.NOT.(N .GT. MAXSIZ))GOTO 23042
      DOFLDS=(-3)
      RETURN
23042 CONTINUE
      FROM(N) = CTOI(BUF, I)
      TO(N) = FROM(N)
      CALL SKIPBL(BUF, I)
      IF(.NOT.(BUF(I) .EQ. 45))GOTO 23044
      I = I + 1
      TO(N) = CTOI(BUF, I)
      CALL SKIPBL(BUF, I)
      GOTO 23045
23044 CONTINUE
      IF(.NOT.(BUF(I) .EQ. 43))GOTO 23046
      I = I + 1
      TO(N) = FROM(N) + CTOI(BUF, I) - 1
      CALL SKIPBL(BUF, I)
23046 CONTINUE
23045 CONTINUE
      IF(.NOT.(FROM(N) .LT. 1 .OR. FROM(N) .GT. TO(N) .OR. (BUF(I) .NE. 
     *44 .AND. BUF(I) .NE. 0)))GOTO 23048
      DOFLDS=(-3)
      RETURN
23048 CONTINUE
      IF(.NOT.(BUF(I) .EQ. 44))GOTO 23050
      I = I + 1
23050 CONTINUE
23040 GOTO 23039
23041 CONTINUE
      I = N + 1
23052 IF(.NOT.(I .LE. MAXSIZ))GOTO 23054
      FROM(I) = HUGE
      TO(I) = HUGE
23053 I = I + 1
      GOTO 23052
23054 CONTINUE
      DOFLDS=(N)
      RETURN
      END
      SUBROUTINE DOTABS(BUF, C, FROM, TO, MAXSIZ)
      LOGICAL*1 BUF(100), C
      INTEGER FROM(100), TO(100), MAXSIZ
      INTEGER I, J, N
      N = 1
      FROM(N) = 1
      TO(N) = HUGE
      J = 1
      I = 1
23055 IF(.NOT.(BUF(I) .NE. 0 .AND. N .LT. MAXSIZ))GOTO 23057
      IF(.NOT.(BUF(I) .EQ. C))GOTO 23058
      N = N + 1
      FROM(N) = J
      TO(N) = I - 1
      J = I + 1
23058 CONTINUE
23056 I = I + 1
      GOTO 23055
23057 CONTINUE
      IF(.NOT.(N .LT. MAXSIZ))GOTO 23060
      N = N + 1
      FROM(N) = J
      TO(N) = HUGE
23060 CONTINUE
23062 IF(.NOT.(N .LT. MAXSIZ))GOTO 23064
      FROM(N+1) = HUGE
      TO(N+1) = HUGE
23063 N = N + 1
      GOTO 23062
23064 CONTINUE
      RETURN
      END
      SUBROUTINE GETFMT(BUF, FMT)
      LOGICAL*1 BUF(100)
      LOGICAL*1 FMT(100)
      INTEGER I, J
      LOGICAL*1 ESC
      INTEGER ADDSET
      J = 1
      I = 1
23065 IF(.NOT.(BUF(I) .NE. 0))GOTO 23067
      IF(.NOT.(BUF(I) .EQ. 36 .AND. BUF(I+1) .GE. 48 .AND. BUF(I+1) .LE.
     * 57))GOTO 23068
      JUNK = ADDSET(-1, FMT, J, 400)
      JUNK = ADDSET(BUF(I+1) - 48 + 1, FMT, J, 400)
      I = I + 1
      GOTO 23069
23068 CONTINUE
      JUNK = ADDSET(ESC(BUF,I), FMT, J, 400)
23069 CONTINUE
23066 I = I + 1
      GOTO 23065
23067 CONTINUE
      FMT(J) = 0
      RETURN
      END
      SUBROUTINE USAGE
      CALL ERROR(55Husage: field [-t[c] | fieldslist] outputformat [file
     *s].)
      RETURN
      END
