Page 1 of 1

COUNTING TIMER

Posted: Fri Apr 23, 2010 1:38 am
by greggarcia
Greeting to all, i am trying to put a simple timer in some applications not lucky so far... i will appreciate some help about this:
have you seen the timer when you hit "Start" the timer start to count seconds and and then minutes and then hours, so you hit the "Stop" button and the timer stop or even better hit the pause button and then "start" again and the timer continue counting..

Thanks so much in advance

Greg Garcia

Re: COUNTING TIMER

Posted: Fri Apr 23, 2010 4:39 pm
by greggarcia
i am apologize i could find some hits using the search option in the forums, but i found the answer very similar that i was looking for under the subject "multiple timer"... thanks now the timer is timing...

Greg Garcia

Re: COUNTING TIMER

Posted: Fri Apr 23, 2010 4:40 pm
by dunbarx
This is a wonderful exercise to learn to program. There are probably a thousand timers out there. Make your own.

As a start, and this is very crude, make two buttons and a field. In the first button, which you will name "start", place these handlers:

Code: Select all

on mouseUp
   if the label of me = "start" then 
      set the label of me to "stop"
      set the startingTime of me to the seconds
      set the oldTime of me to line 1 of fld "timer"
      send "countUp" to me in 1
   else
      set the label of me to "start"
   end if
end mouseUp

on countUp
   put (the seconds - the startingTime of me) + the oldTime of me into fld "timer"
   if the label of btn "start" = "stop" then send "countUp" to me in 1
end countUp
In the second button, named "Reset", place this handler:

Code: Select all

on mouseUp
   put "0" into fld "timer"
   set the label of btn "start" to "start"
end mouseUp
Name the field "timer".

Check it out. We are using a custom property, and more importantly, sending a message in time. You might try rewriting this with a repeat loop in the "start" button, checking for the status of certain criteria. The timer only gives seconds. Rewrite it to your favorite format.

Craig Newman

Re: COUNTING TIMER

Posted: Thu May 20, 2010 12:55 am
by greggarcia
Dumbark sorry for the late reply, thanks for comment, now the timer is working..

best regad
Greg