      SUBROUTINE MAIN
      LOGICAL*1 GETCH
      LOGICAL*1 ARG(402), C, FROM(100), TO(100)
      INTEGER GETARG, LENGTH, MAKSET, XINDEX
      INTEGER ALLBUT, COLLAP, I, LASTTO
      LOGICAL*1 USESTR(21)
      LOGICAL*1 ST001Z(16)
      LOGICAL*1 ST002Z(16)
      LOGICAL*1 ST003Z(14)
      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)/0/
      DATA ST001Z(1)/102/,ST001Z(2)/114/,ST001Z(3)/111/,ST001Z(4)/109/,S
     *T001Z(5)/58/,ST001Z(6)/32/,ST001Z(7)/116/,ST001Z(8)/111/,ST001Z(9)
     */111/,ST001Z(10)/32/,ST001Z(11)/108/,ST001Z(12)/97/,ST001Z(13)/114
     */,ST001Z(14)/103/,ST001Z(15)/101/,ST001Z(16)/0/
      DATA ST002Z(1)/102/,ST002Z(2)/114/,ST002Z(3)/111/,ST002Z(4)/109/,S
     *T002Z(5)/58/,ST002Z(6)/32/,ST002Z(7)/116/,ST002Z(8)/111/,ST002Z(9)
     */111/,ST002Z(10)/32/,ST002Z(11)/108/,ST002Z(12)/97/,ST002Z(13)/114
     */,ST002Z(14)/103/,ST002Z(15)/101/,ST002Z(16)/0/
      DATA ST003Z(1)/116/,ST003Z(2)/111/,ST003Z(3)/58/,ST003Z(4)/32/,ST0
     *03Z(5)/116/,ST003Z(6)/111/,ST003Z(7)/111/,ST003Z(8)/32/,ST003Z(9)/
     *108/,ST003Z(10)/97/,ST003Z(11)/114/,ST003Z(12)/103/,ST003Z(13)/101
     */,ST003Z(14)/0/
      CALL QUERY(USESTR)
      IF (.NOT.(GETARG(1, ARG, 402) .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(ST001Z)
23004 CONTINUE
      GOTO 23003
23002 CONTINUE
      ALLBUT = 0
      IF (.NOT.(MAKSET(ARG, 1, FROM, 100) .EQ. 0))GOTO 23006
      CALL ERROR(ST002Z)
23006 CONTINUE
23003 CONTINUE
23001 CONTINUE
      IF (.NOT.(GETARG(2, ARG, 402) .EQ. -1))GOTO 23008
      TO(1) = 0
      GOTO 23009
23008 CONTINUE
      IF (.NOT.(MAKSET(ARG, 1, TO, 100) .EQ. 0))GOTO 23010
      CALL ERROR(ST003Z)
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
