COUNTING TIMER

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
greggarcia
Posts: 33
Joined: Mon Apr 27, 2009 3:32 pm
Location: Coatzacoalcos, Veracruz, Mexico
Contact:

COUNTING TIMER

Post by greggarcia » Fri Apr 23, 2010 1:38 am

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

greggarcia
Posts: 33
Joined: Mon Apr 27, 2009 3:32 pm
Location: Coatzacoalcos, Veracruz, Mexico
Contact:

Re: COUNTING TIMER

Post by greggarcia » Fri Apr 23, 2010 4:39 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: COUNTING TIMER

Post by dunbarx » Fri Apr 23, 2010 4:40 pm

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

greggarcia
Posts: 33
Joined: Mon Apr 27, 2009 3:32 pm
Location: Coatzacoalcos, Veracruz, Mexico
Contact:

Re: COUNTING TIMER

Post by greggarcia » Thu May 20, 2010 12:55 am

Dumbark sorry for the late reply, thanks for comment, now the timer is working..

best regad
Greg

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”