I'm trying to implement a wait function that will cause my script to momentarily pause. I have included the following code in case anyone wants to reference to why it is not working.
I have tried messing with many different combinations, but have no success.
My function wait() takes one argument, which is set to be the total number of seconds required to wait. Once the function commences, the jscript functions Date() and getTime() are used to set the current time, and to retrieve the current time(in milliseconds). I have debugged the program to send me a note of what the inital time (in milliseconds) is, and a note of what the final time (in milliseconds) is, after the function pauses for sec*1000 milliseconds.
What happens, is the script freezes upon function call, and X seconds later, it displays the inital value and the final value (along with whatever else data was send from the server).
I am using this function to calculate the roundtime needed to wait before continuing with my actions. Any input would be appreciated.
After a little debugging, I found out that the function did actually work, and that I can successfully wait for X seconds before performing another action on the script. Unfortunately, the current implementation I have created will temporarily freeze the screen until the calculation is carried out. Only then, can I continue. While this isn't too big of a problem with running 1-10 second wait() functions, when I create an infinite loop, the application crashes. Could you help me create a way to include an infinite loop in the application without crashing it, and also be able to type in text while the script function is executing? Thanks!
I have tried messing with many different combinations, but have no success.
My function wait() takes one argument, which is set to be the total number of seconds required to wait. Once the function commences, the jscript functions Date() and getTime() are used to set the current time, and to retrieve the current time(in milliseconds). I have debugged the program to send me a note of what the inital time (in milliseconds) is, and a note of what the final time (in milliseconds) is, after the function pauses for sec*1000 milliseconds.
What happens, is the script freezes upon function call, and X seconds later, it displays the inital value and the final value (along with whatever else data was send from the server).
I am using this function to calculate the roundtime needed to wait before continuing with my actions. Any input would be appreciated.
**********************FUNCTION WAIT************************
function wait(sec)
{
world.note("Wait Function");
var i = new Date();
var d = i.getTime();
var t = i.getTime() + sec*1000;
world.note(d);
dateLoop(i,d,t);
}
function dateLoop(a,b,c)
{
for(;;){
a = new Date();
b = a.getTime();
if (b>c)
break;
}
world.note(b);
}
After a little debugging, I found out that the function did actually work, and that I can successfully wait for X seconds before performing another action on the script. Unfortunately, the current implementation I have created will temporarily freeze the screen until the calculation is carried out. Only then, can I continue. While this isn't too big of a problem with running 1-10 second wait() functions, when I create an infinite loop, the application crashes. Could you help me create a way to include an infinite loop in the application without crashing it, and also be able to type in text while the script function is executing? Thanks!