Page 1 of 1

timer

Posted: Tue Sep 10, 2013 12:52 pm
by itay1023
hi,
i would like a code that count backwords one minute (60 seconds).

best regards'
Itay

Re: timer

Posted: Tue Sep 10, 2013 2:00 pm
by BvG

Code: Select all

put the seconds into theCounter
put theCounter into theTime
repeat until theCounter - theTime >= 60
   put 60 - (theCounter - theTime) into field 1
   put the seconds into theCounter
   wait for 0.3 seconds with messages
end repeat
note: it's generally suggested to use send in time, and not repeat in these cases.

Re: timer

Posted: Tue Sep 10, 2013 8:08 pm
by dunbarx
Itay:

Bernd's comment about sending in time is important, because it allows the computer to do other things while the counter is running. A repeat loop takes over everything unless you explicitly look out for other processes. In a button script on a card with a field:

Code: Select all

on mouseUp
   put the seconds into sTime
   put sTime + 60 into eTime
  countdown sTime,eTime
end mouseUp

on countDown sTime,eTime
   if the seconds > eTime then exit to top
   put 60 - (the seconds - sTime) into fld 1
   send "countDown sTime,eTime" to me in 1
end countDown
Note that this script runs much more often than once per second; it usually just reloads the same time value. It still leaves plenty of room for other things to happen, as you will see when you run it.

Craig

Re: timer

Posted: Sun Sep 15, 2013 3:15 pm
by itay1023
It's good!!
Thank you very much!!