[fxruby-users] How to iterate an array automatically

chen li chen_li3 at yahoo.com
Wed Jan 7 09:56:24 EST 2009


>I think you probably want to make the index counters (index1,  
>index2, ...) instance variables instead of local variables. But I  
>guess it's OK otherwise.

Hi Lyle,

Thank you very much.

Now I want to iterate the array automatically on "the radio" once I press the button(instead press it 5 times). How do I  modify the codes below to implement it?

Thanks,

Li

def press_next

@array=["1","2","3","4","5"]
    @current_index = 0
    @radio.text = "#{@array[@current_index}"
    @button_next.connect(SEL_COMMAND) do
      @current_index = @current_index + 1
      @current_index = 0 if @current_index >= @array.length
      @radio.text = "#{@array[@current_index}"
    end

  
end




      


More information about the fxruby-users mailing list