Page 1 of 1

how can i do 2 timers that intercalate each other?

Posted: Sat Jun 20, 2015 11:39 pm
by L.Coder
Hello.

I´m working in two timers that repeat a number of times depending on the variable... I want that the first timer start and count down 20 seconds then the second start and count down 10 seconds.

After that I want that process repeat for the times that the variable says.

this is my card code, Can you help me?

Code: Select all

 

on StartTimers NumberRepeats 
   
   if NumberRepeats = 0 then exit to top
   if fld 1 = 0 then
      put 20 into fld "1"
      subtract 1 from NumberRepeats
   end if
   
  
   subtract 1 from fld "1" 
   send "StartTimers" && NumberRepeats to me in 1 second 
   send "TimerTwo" to me in 1 second 

end StartTimers


on TimerTwo
   
   if fld "2" = 0  then 
      put 10  into fld "2"
   end if
      subtract 1 from fld "2"
      
      
end TimerTwo
 

Re: how can i do 2 timers that intercalate each other?

Posted: Sat Jun 20, 2015 11:58 pm
by Simon
Hi L.Coder,
I haven't really gone over your code but there is a programming ummm... "no-no".

Code: Select all

put 20 into fld "1"
Shouldn't do that even if you have named your field "1" which you shouldn't do either, give it a good name.

Code: Select all

put 20 into fld 1
Will work if it is the lowest layer field that you want to work with. Look in the project browser and the "highest" field (the one at the top) is the "lowest" layered field.

But best just to give them good names

Code: Select all

put 20 into fld "Counter1"
Simon