[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

about timer?

Pat Kiatchaipipat

3/18/2008 7:28:00 AM

hi, I have problem about timer that I want to use with Wxruby.
I want to add 'a' in the text every 1 second.
and this's my code

@textbox4.set_value(subject)
@textbox5.set_value(search)

for i in 0..20

search = search+"a"
@textbox5.set_value(search)

@timer = Timer.new(self,102)
evt_timer(102) { |event| on_timer(search)}
@timer.start(100)

def on_timer(search)
search = search+"a"
@textbox5.set_value(search)
return search
end

end

It show me 'aaaaaaaaaaaaaaaaaaaa' without show 'a' every 1 second. How
can I do it??
--
Posted via http://www.ruby-....

3 Answers

mt

3/18/2008 9:10:00 AM

0

:) i think putting it out of the 0..20 loop might help.

On Tue, Mar 18, 2008 at 3:28 PM, Pat Kiatchaipipat <hb.pat87@hotmail.com> wrote:
> hi, I have problem about timer that I want to use with Wxruby.
> I want to add 'a' in the text every 1 second.
> and this's my code
>
> @textbox4.set_value(subject)
> @textbox5.set_value(search)
>
> for i in 0..20
>
> search = search+"a"
> @textbox5.set_value(search)
>
> @timer = Timer.new(self,102)
> evt_timer(102) { |event| on_timer(search)}
> @timer.start(100)
>
> def on_timer(search)
> search = search+"a"
> @textbox5.set_value(search)
> return search
> end
>
> end
>
> It show me 'aaaaaaaaaaaaaaaaaaaa' without show 'a' every 1 second. How
> can I do it??
> --
> Posted via http://www.ruby-....
>
>

Pat Kiatchaipipat

3/18/2008 9:29:00 AM

0

I try to put out of loop and then it show 'aa'.

First 'a' from
search = search+"a"

and second 'a' from method on_timer.

I want it to show 'a' in 20 time. what should I do :'(
--
Posted via http://www.ruby-....

Pat Kiatchaipipat

3/18/2008 10:49:00 AM

0

I do it now thank you! but I use @timer.start(1000) it do in less than 1
second?? how can I make it in every 1 second??
--
Posted via http://www.ruby-....