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