      SUBROUTINE MAIN
      LOGICAL*1 HEADER(5), TAG(40), BUF(400), CLOWER, FILE(40)
      INTEGER GETLIN, I, GETARG, NMATCH, OUT, OPEN, VERBOS, SCLINE
      DATA HEADER/35, 45, 104, 45, 0/
      DATA TAG(1)/0/
      VERBOS = 0
      I=1
23000 IF(.NOT.(GETARG(I, BUF, 400) .NE. -1))GOTO 23002
      IF(.NOT.(BUF(1) .EQ. 45 .AND. CLOWER(BUF(2)) .EQ. 116))GOTO 23003
      CALL SCOPY(BUF, 3, TAG, 1)
      GOTO 23004
23003 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 63 .AND. BUF(2) .EQ. 0))GOTO 23005
      CALL ERROR(31Husage:  asplit [-tstring] [-v].)
      GOTO 23006
23005 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 45 .AND. CLOWER(BUF(2)) .EQ. 118))GOTO 23007
      VERBOS = 1
      GOTO 23008
23007 CONTINUE
      CALL REMARK(26HIgnoring invalid argument.)
23008 CONTINUE
23006 CONTINUE
23004 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      OUT = 2
23009 IF(.NOT.(GETLIN(BUF, 1) .NE. -1))GOTO 23010
      IF(.NOT.(NMATCH(BUF, 1, HEADER) .GT. 0))GOTO 23011
      CALL CLOSE(OUT)
      IF(.NOT.(SCLINE(BUF, TAG, FILE) .EQ. -3))GOTO 23013
      CALL CANT(BUF)
23013 CONTINUE
      OUT = OPEN(FILE, 2)
      IF(.NOT.(OUT .EQ. -3))GOTO 23015
      CALL CANT(FILE)
23015 CONTINUE
      IF(.NOT.(VERBOS .EQ. 1))GOTO 23017
      CALL REMARK(FILE)
23017 CONTINUE
      GOTO 23012
23011 CONTINUE
      CALL PUTLIN(BUF, OUT)
23012 CONTINUE
      GOTO 23009
23010 CONTINUE
      RETURN
      END
      INTEGER FUNCTION SCLINE(BUF, TAG, FILE)
      LOGICAL*1 BUF(100), TAG(100), FILE(100), TYPE, C
      INTEGER I, J
      I=1
23019 IF(.NOT.(BUF(I) .NE. 32))GOTO 23021
23020 I=I+1
      GOTO 23019
23021 CONTINUE
      CALL SKIPBL(BUF, I)
      C = TYPE(BUF(I))
      J=1
23022 IF(.NOT.(C .EQ. 1 .OR. C .EQ. 2 .OR. C .EQ. 46))GOTO 23024
      FILE(J) = BUF(I)
      I = I + 1
      C = TYPE(BUF(I))
23023 J=J+1
      GOTO 23022
23024 CONTINUE
      IF(.NOT.(J .EQ. 1))GOTO 23025
      SCLINE = -3
      GOTO 23026
23025 CONTINUE
      CALL SCOPY(TAG, 1, FILE, J)
      SCLINE = 0
23026 CONTINUE
      RETURN
      END
      INTEGER FUNCTION NMATCH(LIN, FROM, PAT)
      LOGICAL*1 LIN(400), PAT(100)
      INTEGER FROM, I, J
      I = FROM
      J=1
23027 IF(.NOT.(PAT(J) .NE. 0))GOTO 23029
      IF(.NOT.(LIN(I) .NE. PAT(J)))GOTO 23030
      NMATCH = 0
      RETURN
23030 CONTINUE
      I = I + 1
23028 J = J + 1
      GOTO 23027
23029 CONTINUE
      NMATCH = I
      RETURN
      END
