      SUBROUTINE MAIN
      LOGICAL*1 GETC
      LOGICAL*1 ARG(400), C, FROM(100), TO(100)
      INTEGER GETARG, LENGTH, MAKSET, XINDEX
      INTEGER ALLBUT, COLLAP, I, LASTTO
      IF(.NOT.(GETARG(1, ARG, 400) .EQ. -1 .OR. (ARG(1) .EQ. 63 .AND. AR
     *G(2) .EQ. 0)))GOTO 23000
      CALL ERROR(18Husage: tr from to.)
      GOTO 23001
23000 CONTINUE
      IF(.NOT.(ARG(1) .EQ.  33))GOTO 23002
      ALLBUT = 1
      IF(.NOT.(MAKSET(ARG, 2, FROM, 100) .EQ. 0))GOTO 23004
      CALL ERROR(16Hfrom: too large.)
23004 CONTINUE
      GOTO 23003
23002 CONTINUE
      ALLBUT = 0
      IF(.NOT.(MAKSET(ARG, 1, FROM, 100) .EQ. 0))GOTO 23006
      CALL ERROR(16Hfrom: too large.)
23006 CONTINUE
23003 CONTINUE
23001 CONTINUE
      IF(.NOT.(GETARG(2, ARG, 400) .EQ. -1))GOTO 23008
      TO(1) = 0
      GOTO 23009
23008 CONTINUE
      IF(.NOT.(MAKSET(ARG, 1, TO, 100) .EQ. 0))GOTO 23010
      CALL ERROR(14Hto: too large.)
23010 CONTINUE
23009 CONTINUE
      LASTTO = LENGTH(TO)
      IF(.NOT.(LENGTH(FROM) .GT. LASTTO .OR. ALLBUT .EQ. 1))GOTO 23012
      COLLAP = 1
      GOTO 23013
23012 CONTINUE
      COLLAP = 0
23013 CONTINUE
23014 CONTINUE
      I = XINDEX(FROM, GETC(C), ALLBUT, LASTTO)
      IF(.NOT.(COLLAP .EQ. 1 .AND. I .GE. LASTTO .AND. LASTTO .GT. 0))GO
     *TO 23017
      CALL PUTC(TO(LASTTO))
23019 CONTINUE
      I = XINDEX(FROM, GETC(C), ALLBUT, LASTTO)
23020 IF(.NOT.(I .LT. LASTTO))GOTO 23019
23021 CONTINUE
23017 CONTINUE
      IF(.NOT.(C .EQ. -1))GOTO 23022
      GOTO 23016
23022 CONTINUE
      IF(.NOT.(I .GT. 0 .AND. LASTTO .GT. 0))GOTO 23024
      CALL PUTC(TO(I))
      GOTO 23025
23024 CONTINUE
      IF(.NOT.(I .EQ. 0))GOTO 23026
      CALL PUTC(C)
23026 CONTINUE
23025 CONTINUE
23015 GOTO 23014
23016 CONTINUE
      RETURN
      END
      INTEGER FUNCTION MAKSET(ARRAY, K, SET, SIZE)
      INTEGER ADDSET
      INTEGER I, J, K, SIZE
      LOGICAL*1 ARRAY(100), SET(SIZE)
      I = K
      J = 1
      CALL FILSET(0, ARRAY, I, SET, J, SIZE)
      MAKSET = ADDSET(0, SET, J, SIZE)
      RETURN
      END
      INTEGER FUNCTION XINDEX(ARRAY, C, ALLBUT, LASTTO)
      LOGICAL*1 ARRAY(100), C
      INTEGER INDEX
      INTEGER ALLBUT, LASTTO
      IF(.NOT.(C .EQ. -1))GOTO 23028
      XINDEX = 0
      GOTO 23029
23028 CONTINUE
      IF(.NOT.(ALLBUT .EQ. 0))GOTO 23030
      XINDEX = INDEX(ARRAY, C)
      GOTO 23031
23030 CONTINUE
      IF(.NOT.(INDEX(ARRAY, C) .GT. 0))GOTO 23032
      XINDEX = 0
      GOTO 23033
23032 CONTINUE
      XINDEX = LASTTO + 1
23033 CONTINUE
23031 CONTINUE
23029 CONTINUE
      RETURN
      END
