Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
59
rated 0 times [  65] [ 6]  / answers: 1 / hits: 16878  / 12 Years ago, tue, february 19, 2013, 12:00:00

I have a function that interfaces with a telephony program, and calls people. I want to know, is there a method that I can use to call folks for a certain amount of time?



I'd like to run a loop like:



while(flag = 0){
call(people);

if(<ten minutes have passed>){
flag = 1;
}
}


Any help would be appreciated.


More From » timing

 Answers
41

You probably want the setTimeout() function.



Something like this should work (untested):



var keepCalling = true;
setTimeout(function () {
keepCalling = false;
}, 60000);

while (keepCalling) {
callPeople();
}


An alternative method if you're having problems with setTimeout():



var startTime = Date.now();
while ((Date.now() - startTime) < 60000) {
callPeople();
}

[#80119] Monday, February 18, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arlethjeanettep

Total Points: 506
Total Questions: 96
Total Answers: 79

Location: Liberia
Member since Tue, Mar 14, 2023
1 Year ago
;