def add_range_opts(fkey, lkey)
      @oparse.on("-r", "--range=START[:END]", 
                 "Start and optional end range") do |r|

        raise "-x and -r are mutually exclusive" if @parser_got_range
        @parser_got_range=true

        unless /^(-?[0-9]+)(?::(-?[0-9]+))?$/.match(r)
          raise "invalid range #{r.inspect}"
        end

        @opts[fkey] = $1.to_i
        @opts[lkey] = $2.to_i if $2
      end

      @oparse.on("-x", "--hexrange=START[:END]", 
                 "Start and optional end range in hex") do |r|

        raise "-x and -r are mutually exclusive" if @parser_got_range
        @parser_got_range=true

        unless /^(-?[0-9a-f]+)(?::(-?[0-9a-f]+))?$/i.match(r)
          raise "invalid range #{r.inspect}"
        end

        @opts[fkey] = 
          if ($1[0,1] == '-')
            ($1[1..-1]).hex_to_num * -1
          else
            $1.hex_to_num
          end

        if $2
          @opts[lkey] = 
            if($2[0,1] == '-')
              $2[1..-1].hex_to_num * -1
            else
              $2.hex_to_num
            end
        end
      end
    end
def add_range_opts(fkey, lkey)
      @oparse.on("-r", "--range=START[:END]", 
                 "Start and optional end range") do |r|

        raise "-x and -r are mutually exclusive" if @parser_got_range
        @parser_got_range=true

        unless /^(-?[0-9]+)(?::(-?[0-9]+))?$/.match(r)
          raise "invalid range #{r.inspect}"
        end

        @opts[fkey] = $1.to_i
        @opts[lkey] = $2.to_i if $2
      end

      @oparse.on("-x", "--hexrange=START[:END]", 
                 "Start and optional end range in hex") do |r|

        raise "-x and -r are mutually exclusive" if @parser_got_range
        @parser_got_range=true

        unless /^(-?[0-9a-f]+)(?::(-?[0-9a-f]+))?$/i.match(r)
          raise "invalid range #{r.inspect}"
        end

        @opts[fkey] = 
          if ($1[0,1] == '-')
            ($1[1..-1]).hex_to_num * -1
          else
            $1.hex_to_num
          end

        if $2
          @opts[lkey] = 
            if($2[0,1] == '-')
              $2[1..-1].hex_to_num * -1
            else
              $2.hex_to_num
            end
        end
      end
    end
Implements numeric and hex range options via '-r' and '-x'

 Takes two arguments which are the @opts hash key names for
 first and last parameters.

 (Used commonly throughout several executables)