It didn't do what I wanted. It delayed the execution of EACH repetition of the loop, extending 8 seconds of execution to over a minute.
One thing is that there is no "single function" for the long calculation. It depends on which button is pushed on the form.
function button1(){ // activated by pushing button number one
var a, b, c, d, e, l1, l2, maxa, max1, max2;
getgrid(a, b, c, d, e); // this is the error printing function
for(l1 = 0; l1 < d; l1++){
for(l2 = 0; l2 < e; l2++){
calcgrid(a, b, c, l1, l2); // this function takes time
checkgrid(a, l1, l2, maxa, max1, max2);
}
};
putgrid(maxa, b, c, max1, max2);
};
function button2(){ // activated by pushing button number two
var a, b, c, d, e,, l1 l2, maxa, max1, max2;
getgrid(a, b, c, d, e); // this is the error printing function
for(l2 = 0; l2 < e; l2++){
calcgrid(a, b, c, d, l2); // this function takes time
checkgrid(a, d, l2, maxa, max1, max2);
};
putgrid(maxa, b, c, max1, max2);
};
function button3(){ // activated by pushing button number three
var a, b, c, d, e, l1, l2, maxa, max1, max2;
getgrid(a, b, c, d, e); // this is the error printing function
for(l1 = 0; l1 < d; l1++){
calcgrid(a, b, c, l1, e); // this function takes time
checkgrid(a, l1, e, maxa, max1, max2);
};
putgrid(maxa, b, c, max1, max2);
};
function button4(){ // activated by pushing button number four
var a, b, c, d, e, l1, l2, maxa, max1, max2;
getgrid(a, b, c, d, e); // this error printing function
calcgrid(a, b, c, d, e); // this is the function takes time
checkgrid(a, d, e, maxa, max1, max2);
putgrid(maxa, b, c, max1, max2);
};
I can't figure out where to put the setInterval without causing multiple delays, because there is no "single function" to call only once.
The setInterval function seems to delay only the function attached to it. I need to delay execution of EVERYTHING after the getgrid function. Yet, all of those other items must execute in the proper order, or the wrong valuyes are used by following functions.
Is there a way to put something right after the getgrid function and before the for loop that delays the following statements to let the output occur?