      SUBROUTINE MAIN
      LOGICAL*1 GETCH
      LOGICAL*1 ARG(512), C, FROM(100), TO(100)
      INTEGER GETARG, LENGTH, MAKSET, XINDEX
      INTEGER ALLBUT, COLLAP, I, LASTTO
      LOGICAL*1 USESTR(22)
      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
     *16/,USESTR(10)/114/,USESTR(11)/32/,USESTR(12)/102/,USESTR(13)/114/
     *,USESTR(14)/111/,USESTR(15)/109/,USESTR(16)/32/,USESTR(17)/91/,USE
     *STR(18)/116/,USESTR(19)/111/,USESTR(20)/93/,USESTR(21)/46/,USESTR(
     *22)/0/
      CALL QUERY(USESTR)
      IF (.NOT.(GETARG(1, ARG, 512) .EQ. -1))GOTO 23000
      CALL ERROR(USESTR)
      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, 512) .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, GETCH(C,1), ALLBUT, LASTTO)
      IF (.NOT.(COLLAP .EQ. 1 .AND. I .GE. LASTTO .AND. LASTTO .GT. 0))G
     *OTO 23017
      CALL PUTCH(TO(LASTTO),2)
23019 CONTINUE
      I = XINDEX(FROM, GETCH(C,1), 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 PUTCH(TO(I),2)
      GOTO 23025
23024 CONTINUE
      IF (.NOT.(I .EQ. 0))GOTO 23026
      CALL PUTCH(C,2)
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 INDEXC
      INTEGER ALLBUT, LASTTO
      IF (.NOT.(C .EQ. -1))GOTO 23028
      XINDEX = 0
      GOTO 23029
23028 CONTINUE
      IF (.NOT.(ALLBUT .EQ. 0))GOTO 23030
      XINDEX = INDEXC(ARRAY, C)
      GOTO 23031
23030 CONTINUE
      IF (.NOT.(INDEXC(ARRAY, C) .GT. 0))GOTO 23032
      XINDEX = 0
      GOTO 23033
23032 CONTINUE
      XINDEX = LASTTO + 1
23033 CONTINUE
23031 CONTINUE
23029 CONTINUE
      RETURN
      END
