[Newbies] Implementing a simple timer

Jan Teske jan.teske at student.hpi.uni-potsdam.de
Thu Dec 15 22:51:59 UTC 2011


I'm trying to write a simple timer using a TextMorph and its step 
method. It should count up every 1 second so I've set stepTime to 1000. 
My step method looks as follows:

     step
         self time: self time + 1.
         self contents: self time asString

That should work. But I discover one problem: The timer counts up but it 
does so way to fast. If I print the numbers onto the Transcript 
everything works fine. So I think the problem lies within the TextMorph. 
It seems that during the sent of 'self contents:' the step method is 
called again so that it is executed long before the stepTime is up.

Am I right with that suspicion? Can anyone think of a way to work around 
my problem?

Thanks in advance!


More information about the Beginners mailing list