Hello
Is there a timer functionality where you start a timer and when it finishes you execute some code?
Is there a timer functionality where you start a timer and when it finishes you execute some code?
debugClear();
var bGotIt = false;
var timerStart = 0;
var vTimelimit = 5;//set timer to 30 seconds
var stopTime = false;
function main() {
var timerNow;
var vTimeA = new Date();//vTimeA = the number of milliseconds since January 1, 1970 00:00:00
if (bGotIt == false) {
timerStart = (vTimeA)*1;
bGotIt = true;
}
timerNow = (vTimeA)*1;
var timeLapsed = (timerNow-timerStart)/1000;
if(timeLapsed < vTimelimit){
//place code here
if(timeLapsed>0) debugPrintln("timeLapsed = "+timeLapsed + " Seconds");
}else{//resets the timer every "vTimelimit" seconds or comment out if I just need a timer one time.
if(!stopTime){
debugPrintln("Total Seconds Lapsed: "+timeLapsed);
stopTime = true;
}
timeLapsed = 0;
}
// debugPrintln("timeLapsed = "+timeLapsed);
return;
}
Comment