      SUBROUTINE MAIN
      LOGICAL*1 CH, CL, ROOT(40), FILE(40)
      INTEGER I, VERBOS, STATUS
      INTEGER GETARG, EQUAL, CPYMSG
      LOGICAL*1 DFROOT(5)
      LOGICAL*1 MINUSV(3)
      DATA DFROOT(1)/116/,DFROOT(2)/109/,DFROOT(3)/115/,DFROOT(4)/103/,D
     *FROOT(5)/0/
      DATA MINUSV(1)/45/,MINUSV(2)/118/,MINUSV(3)/0/
      DATA CH/97/
      DATA CL/97/
      CALL QUERY(33Husage:  msplit <file [-v] [root].)
      VERBOS = 0
      CALL SCOPY(DFROOT, 1, ROOT, 1)
      I=1
23000 IF (.NOT.(GETARG(I, FILE, 40) .NE. -1))GOTO 23002
      CALL FOLD(FILE)
      IF (.NOT.(EQUAL(FILE, MINUSV) .EQ. 1))GOTO 23003
      VERBOS = 1
      GOTO 23004
23003 CONTINUE
      CALL SCOPY(FILE, 1, ROOT, 1)
23004 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
23005 CONTINUE
      I = 1
      CALL STCOPY(ROOT, 1, FILE, I)
      CALL CHCOPY(CH, FILE, I)
      CALL CHCOPY(CL, FILE, I)
      FILE(I) = 0
      I = 50 - 1
      STATUS = CPYMSG(I, FILE)
      IF (.NOT.(VERBOS .EQ. 1))GOTO 23008
      CALL REMARK(FILE)
23008 CONTINUE
      CL = CL + 1
      IF (.NOT.(CL .GT. 122))GOTO 23010
      CL = 97
      CH = CH + 1
23010 CONTINUE
23006 IF (.NOT.(STATUS .EQ. -1))GOTO 23005
23007 CONTINUE
      RETURN
      END
      INTEGER FUNCTION CPYMSG(N, FILE)
      INTEGER N, OUT, I, STATUS, JUNK
      INTEGER CREATE, GETLIN, EQUAL, NOTE
      INTEGER*4 TEMP
      LOGICAL*1 FILE(40), HDRPAT(4), BUF(512)
      DATA HDRPAT/1, 1, 10, 0/
      OUT = CREATE(FILE, 2)
      IF (.NOT.(OUT .EQ. -3))GOTO 23012
      CALL CANT(FILE)
23012 CONTINUE
      I = 0
23014 CONTINUE
      JUNK = NOTE(TEMP, 1)
      STATUS = GETLIN(BUF, 1)
      IF (.NOT.(STATUS .EQ. -1))GOTO 23017
      GOTO 23016
23017 CONTINUE
      IF (.NOT.(EQUAL(BUF, HDRPAT) .EQ. 1))GOTO 23019
      I = I + 1
      IF (.NOT.(I .GT. N))GOTO 23021
      CALL SEEK(TEMP, 1)
      STATUS = N
      GOTO 23016
23021 CONTINUE
23019 CONTINUE
      CALL PUTLIN(BUF, OUT)
23015 GOTO 23014
23016 CONTINUE
      CALL CLOSE(OUT)
      CPYMSG = STATUS
      RETURN
      END
