[fxruby-users] FXTable iterators bug

Philippe Lang philippe.lang at attiksystem.ch
Thu Oct 5 05:38:19 EDT 2006


Hi,

I'm unable to use the FXTable iterators "each_row" and "each_column". When writing this kind of code:

   @table.each_row do |r|
   end
            
I get the error:

c:/ruby/lib/ruby/site_ruby/1.8/fox16/iterators.rb:95:in `each_row': 
undefined local variable or method `getNumCols' for #<MyFXTable:0xbb91d8c> (NameError)

When looking at the documentation, I can see the code for these iterators is:

# File lib/fox16/iterators.rb, line 92
    def each_row # :yields: itemArray
      0.upto(getNumRows - 1) do |i|
        tableRow = []
        0.upto(getNumCols - 1) do |j|
          tableRow << getItem(i, j)
        end
        yield tableRow
      end
      self
    end

# File lib/fox16/iterators.rb, line 107
    def each_column # :yields: itemArray
      0.upto(getNumCols - 1) do |j|
        tableCol = []
        0.upto(getNumRows - 1) do |i|
          tableCol << getItem(i, j)
        end
        yield tableCol
      end
      self
    end


I cannot find any reference to "getNumRows" and "getNumCols" in FXRuby. I think it should be instead:

# File lib/fox16/iterators.rb, line 92
    def each_row # :yields: itemArray
      0.upto(numRows - 1) do |i|
        tableRow = []
        0.upto(numColumns - 1) do |j|
          tableRow << getItem(i, j)
        end
        yield tableRow
      end
      self
    end

# File lib/fox16/iterators.rb, line 107
    def each_column # :yields: itemArray
      0.upto(numColumns - 1) do |j|
        tableCol = []
        0.upto(numRows - 1) do |i|
          tableCol << getItem(i, j)
        end
        yield tableCol
      end
      self
    end


Cheers,

---------------
Philippe Lang
Attik System

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3125 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20061005/a64bfab2/attachment.bin 


More information about the fxruby-users mailing list