[fxruby-users] How to iterate an array within an event

chen li chen_li3 at yahoo.com
Tue Jan 6 16:17:33 EST 2009


Hi Lyle,

Thank you very much. I think I grasp the idea/format on how to do the iteration  in FXRuby by reading your code.


One more question: I want to iterate a slice(here is 5) from an array. Here is my code. Is it the best way to iterate a slice?


Li

######################
def press_next
	@all=("1".."1000")

		index1=0
		index2=1
		index3=2
		index4=3
		index5=4
	@button_next.connect(SEL_COMMAND) do
		index1,index2,index3,index4,index5=[index1,index2,index3,index4,index5].sort_by{rand}

		@radio1.text=@all[index1]
		@radio2.text=@all[index2]
		@radio3.text=@all[index3]
		@radio4.text=@all[index4]
		@radio5.text=@all[index5]

		index1	+=5
		index2	+=5
		index3	+=5
		index4	+=5
		index5	+=5
	end
end








      


More information about the fxruby-users mailing list