CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Pausing while a function works ... (http://www.codingforums.com/showthread.php?t=283684)

SlowCoder 12-06-2012 08:38 PM

Pausing while a function works ...
 
I've written a RollDice() function that animates the rolling of dice. The function uses setTimeout to call itself a number of times. A variable DiceRolling is true when the routine is running, and once complete, DiceRolling is set false.

I have other automated routines that need to run after the routine is completed.

What is the best way to "pause" my script until the RollDice routine has completed?

felgall 12-06-2012 09:27 PM

Quote:

Originally Posted by SlowCoder (Post 1297854)
I've written a RollDice() function that animates the rolling of dice. The function uses setTimeout to call itself a number of times. A variable DiceRolling is true when the routine is running, and once complete, DiceRolling is set false.

I have other automated routines that need to run after the routine is completed.

What is the best way to "pause" my script until the RollDice routine has completed?

Split it into two scripts at the point where you want it to pause. Call the second script when the pause period is over.

Old Pedant 12-06-2012 10:57 PM

Or, if it makes sense in the logic of the overall program, RIGHT AFTER you set the DiceRolling flag back to false call the continuation code.


All times are GMT +1. The time now is 08:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.