      SUBROUTINE MAIN
      LOGICAL*1 BUF(512), TABC
      INTEGER FROM(10), TO(10)
      LOGICAL*1 OFMT(512)
      INTEGER I, J, K, N, NFLDS, LEN, FD, TFLAG, FILES
      INTEGER GETARG, GETLIN, OPEN, DOFLDS, GETFMT
      LOGICAL*1 USESTR(58)
      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
     *02/,USESTR(10)/105/,USESTR(11)/101/,USESTR(12)/108/,USESTR(13)/100
     */,USESTR(14)/32/,USESTR(15)/91/,USESTR(16)/45/,USESTR(17)/116/,USE
     *STR(18)/91/,USESTR(19)/99/,USESTR(20)/93/,USESTR(21)/32/,USESTR(22
     *)/124/,USESTR(23)/32/,USESTR(24)/102/,USESTR(25)/105/,USESTR(26)/1
     *01/,USESTR(27)/108/,USESTR(28)/100/,USESTR(29)/108/,USESTR(30)/105
     */,USESTR(31)/115/,USESTR(32)/116/,USESTR(33)/93/,USESTR(34)/32/,US
     *ESTR(35)/111/,USESTR(36)/117/,USESTR(37)/116/,USESTR(38)/112/,USES
     *TR(39)/117/,USESTR(40)/116/,USESTR(41)/102/,USESTR(42)/111/,USESTR
     *(43)/114/,USESTR(44)/109/,USESTR(45)/97/,USESTR(46)/116/,USESTR(47
     *)/32/,USESTR(48)/91/,USESTR(49)/102/,USESTR(50)/105/,USESTR(51)/10
     *8/,USESTR(52)/101/,USESTR(53)/93/,USESTR(54)/32/,USESTR(55)/46/,US
     *ESTR(56)/46/,USESTR(57)/46/,USESTR(58)/0/
      DATA TABC /9/, TFLAG /1/, NFLDS /10/
      CALL QUERY(USESTR)
      I = 1
      IF (.NOT.(GETARG(1, BUF, 512) .EQ. -1))GOTO 23000
      CALL ERROR(USESTR)
23000 CONTINUE
      IF (.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 116))GOTO 23002
      IF (.NOT.(BUF(3) .NE. 0))GOTO 23004
      TABC = BUF(3)
23004 CONTINUE
      I = 2
      GOTO 23003
23002 CONTINUE
      IF (.NOT.(BUF(1) .GE. 48 .AND. BUF(1) .LE. 57))GOTO 23006
      NFLDS = DOFLDS(BUF, FROM, TO, 10)
      IF (.NOT.(NFLDS .EQ. -3))GOTO 23008
      CALL ERROR (28Hillegal field specification.)
23008 CONTINUE
      TFLAG = 0
      I = 2
23006 CONTINUE
23003 CONTINUE
      IF (.NOT.(GETARG(I, BUF, 512) .EQ. -1))GOTO 23010
      CALL ERROR(USESTR)
23010 CONTINUE
      JUNK = GETFMT(BUF, OFMT)
      FILES = 0
      I=I+1
23012 CONTINUE
      IF (.NOT.(GETARG(I, BUF, 512) .EQ. -1))GOTO 23015
      IF (.NOT.(FILES .EQ. 1))GOTO 23017
      GOTO 23014
23017 CONTINUE
      FD = 1
      GOTO 23016
23015 CONTINUE
      IF (.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23019
      FD = 1
      GOTO 23020
23019 CONTINUE
      FD = OPEN(BUF, 1)
23020 CONTINUE
23016 CONTINUE
      FILES = 1
      IF (.NOT.(FD .EQ. -3))GOTO 23021
      CALL CANT(BUF)
23021 CONTINUE
      LEN = GETLIN(BUF, FD)
23023 IF (.NOT.(LEN .NE. -1))GOTO 23024
      IF (.NOT.(TFLAG .EQ. 1))GOTO 23025
      CALL DOTABS(BUF, TABC, FROM, TO, NFLDS)
23025 CONTINUE
      J = 1
23027 IF (.NOT.(OFMT(J) .NE. 0))GOTO 23029
      IF (.NOT.(OFMT(J) .EQ. -1))GOTO 23030
      N = OFMT(J+1)
      K = FROM(N)
23032 IF (.NOT.(K .LE. TO(N) .AND. K .LT. LEN))GOTO 23034
      CALL PUTCH(BUF(K), 2)
23033 K = K + 1
      GOTO 23032
23034 CONTINUE
      J = J + 1
      GOTO 23031
23030 CONTINUE
      CALL PUTCH(OFMT(J), 2)
23031 CONTINUE
23028 J = J + 1
      GOTO 23027
23029 CONTINUE
      CALL PUTCH(10, 2)
      LEN = GETLIN(BUF, FD)
      GOTO 23023
23024 CONTINUE
      IF (.NOT.(FD .NE. 1))GOTO 23035
      CALL CLOSE(FD)
23035 CONTINUE
23013 I=I+1
      GOTO 23012
23014 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) = 30000
      I = 1
23037 IF (.NOT.(BUF(I) .NE. 0))GOTO 23039
      N = N + 1
      IF (.NOT.(N .GT. MAXSIZ))GOTO 23040
      DOFLDS=(-3)
      RETURN
23040 CONTINUE
      FROM(N) = CTOI(BUF, I)
      TO(N) = FROM(N)
      CALL SKIPBL(BUF, I)
      IF (.NOT.(BUF(I) .EQ. 45))GOTO 23042
      I = I + 1
      TO(N) = CTOI(BUF, I)
      CALL SKIPBL(BUF, I)
      GOTO 23043
23042 CONTINUE
      IF (.NOT.(BUF(I) .EQ. 43))GOTO 23044
      I = I + 1
      TO(N) = FROM(N) + CTOI(BUF, I) - 1
      CALL SKIPBL(BUF, I)
23044 CONTINUE
23043 CONTINUE
      IF (.NOT.(FROM(N) .LT. 1 .OR. FROM(N) .GT. TO(N) .OR. (BUF(I) .NE.
     * 44 .AND. BUF(I) .NE. 0)))GOTO 23046
      DOFLDS=(-3)
      RETURN
23046 CONTINUE
      IF (.NOT.(BUF(I) .EQ. 44))GOTO 23048
      I = I + 1
23048 CONTINUE
23038 GOTO 23037
23039 CONTINUE
      I = N + 1
23050 IF (.NOT.(I .LE. MAXSIZ))GOTO 23052
      FROM(I) = 30000
      TO(I) = 30000
23051 I = I + 1
      GOTO 23050
23052 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) = 30000
      J = 1
      I = 1
23053 IF (.NOT.(BUF(I) .NE. 0 .AND. N .LT. MAXSIZ))GOTO 23055
      IF (.NOT.(BUF(I) .EQ. C))GOTO 23056
      N = N + 1
      FROM(N) = J
      TO(N) = I - 1
      J = I + 1
23056 CONTINUE
23054 I = I + 1
      GOTO 23053
23055 CONTINUE
      IF (.NOT.(N .LT. MAXSIZ))GOTO 23058
      N = N + 1
      FROM(N) = J
      TO(N) = 30000
23058 CONTINUE
23060 IF (.NOT.(N .LT. MAXSIZ))GOTO 23062
      FROM(N+1) = 30000
      TO(N+1) = 30000
23061 N = N + 1
      GOTO 23060
23062 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
23063 IF (.NOT.(BUF(I) .NE. 0))GOTO 23065
      IF (.NOT.(BUF(I) .EQ. 36 .AND. BUF(I+1) .GE. 48 .AND. BUF(I+1) .LE
     *. 57))GOTO 23066
      JUNK = ADDSET(-1, FMT, J, 512)
      JUNK = ADDSET(BUF(I+1) - 48 + 1, FMT, J, 512)
      I = I + 1
      GOTO 23067
23066 CONTINUE
      JUNK = ADDSET(ESC(BUF,I), FMT, J, 512)
23067 CONTINUE
23064 I = I + 1
      GOTO 23063
23065 CONTINUE
      FMT(J) = 0
      RETURN
      END
