There is absolutely no guarantee how often #step will actually be called. The given #stepTime is just a recommendation to the system. To make your code work you should use something like:
MyTimer>>startTimer "Start the timer" timerStarted := Time totalSeconds.
MyTimer>>step "Update my timer" self time: Time totalSeconds - timerStarted.
Cheers, - Andreas
On 12/15/2011 23:51, Jan Teske wrote:
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!