Timer

Klaus Major k_major at osnabrueck.netsurf.de
Fri Dec 14 08:58:00 EST 2001


Hi  Domi,

> I want to rewrite a little timer I had in HC -- without resorting to 
> "wait" or "idle" which are not recommended in MC...
> ...
> put 10 into field "temps"
> repeat 10 times
>   send "mouseup" to field "temps" in 1 second
> end repeat
> The field script:
> on mouseup
>   subtract 1 from me
> end mouseup
> The problem: it seems that the loop send all the commands at once, and 
> doesn't "wait" for the 1 second delay...

That is true and the way computers work...

Try this:
Note that you just need this script in the "starting" button.
No script required for the field !

on mouseup
   put "10" into fld "temps"
   send "diminuendo" to me in 1 secs
end mouseup

on diminuendo # ;-)
  if fld "temps" is not "0" then  ## timer is not yet finished !
     subtract 1 from fld "temps"
     send "diminuendo" to me in 1 secs
  end if
end diminuendo


This sends the message every 1 second until the content of fld "temps"
is 0, which means the timer did his work :-)

Hope this helps...

Au revoir


Klaus Major
k_major at osnabrueck.netsurf.de




More information about the metacard mailing list