Stopwatch timers

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Stopwatch timers

Post by catalinanesia » Fri Jun 26, 2015 4:33 pm

Hi everyone,
I have a project in development for Android involving many Stopwatch timing
(never done a Stopwatch in LC but should be easy right?) but I have a question
regarding the approach I should take:

I have 8 physical processes to time so I will have 8 Stopwatches, one for each process but
how should I think in constructing the logic so that I can define only 4 Stopwaches to be presented
on the Main Stopwatch Interface ?

Is it possible to have one or many objects (a group with all the graphics, buttons and labels or fields necessary to define a complete Stopwatch)
called "StopwatchA, B,C, etc" on a card and from there to select the ones I want to use at that specific moment for different timing processes and to be added
on the Main Stopwatch Interface...

Any guidance is welcomed,
Catalin

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: Stopwatch timers

Post by zaxos » Fri Jun 26, 2015 4:54 pm

Group your objects and then do something like this:

Code: Select all

on mouseUp -- or something else
if the hilite of btn "Stopwatch 1" then
set the visible of grp "StopWatchA" to true -- or show grp "StopWatchA"
else
set th visible of grp "StopWatchA" to false -- or hide grp "StopWatchA"
end if
if the hilite of btn "Stopwatch 2" then
set the visible of grp "StopWatchB" to true
else
set the visible of grp "StopWatchB" to false
end if
set the visible of grp "StopWatchC" to false
set the visible of grp "StopWatchD" to false
end mouseUp
hiding the group also hides the objects in it.Hope this applies for mobile too.
Or maybe create a different card for each stopwatch and have a main group that is shared between the cards?
Knowledge is meant to be shared.

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Stopwatch timers

Post by catalinanesia » Fri Jun 26, 2015 5:01 pm

Thanks! Zaxos,
Your first approach looks easy enough to be implemented by me but I am more
curious about the second option:

"Or maybe create a different card for each stopwatch and have a main group that is shared between the cards?"

will you elaborate a bit on this one? not necessary the working code just the logic ...

Thanks!
Catalin

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: Stopwatch timers

Post by zaxos » Fri Jun 26, 2015 5:21 pm

Sure, the main group should contain the objects that you want to be allways visible in every card, the field with the time maybe? And ofc whateve else you think should be in the group, to share the group between the cards right click on it in the project browser choose Property inspector and from there click on "Behave like background", this will share the group between every card, same place, same data. And from there you could check the time in the timeField and do your actions based on it:

Code: Select all

on mainLoop
   put fld "timeField" into theTime
   if theTime > "100" then
      go card "StopWatch1"
   else if theTime > "500" then
      go card "StopWatch2"
   else if theTime > "1000" then
      go card "StopWatch3"
   end if
   send mainLoop to me in 30 millisec
end mainLoop
Knowledge is meant to be shared.

catalinanesia
Posts: 83
Joined: Sun Feb 16, 2014 10:08 pm

Re: Stopwatch timers

Post by catalinanesia » Fri Jun 26, 2015 6:23 pm

Thanks for guidance,
I will post further on when I get to that step, at this time I am planing the logic and
review the structure ...

Regards!

Post Reply