If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Although the original question concerned how to pause the execution of the program, might I suggest a different approach to accomplish your objective. Assuming that your code works, except for delays, you might want to set the CSS on your hexagons (either visibility or display) so that they can't be seen when they're drawn. Draw them all, even though the user can't see them, and then use a procedure like I've shown you to make them visible at intervals. That way you wouldn't really have to modify your existing code to any great extent.

will make a time reference, add 1000 to it (1 second in milliseconds) then loop until the new time reference has passed by at lease 1000 milliseconds, note that it is not counting a value.

And if you use this to create a "pause" and you set it for a sufficient period of time your browser will flash the user a "long running script" message. Set it for 20 minutes and see, although it should only take about 4 or 5 minutes. And it doesn't matter if a single pause isn't sufficient, what counts is how long the entire script takes to run.

Secondly, if you have some other javascript functionality built into the page, such as clicking on an element to do whatever, you'll find that it really has problems working while your pause loop is running.

A function that is executed as a result of setTimeout is different. It starts out with a brand new instance of the "browser timer" so you don't have this problem.

And if you use this to create a "pause" and you set it for a sufficient period of time your browser will flash the user a "long running script" message. Set it for 20 minutes and see, although it should only take about 4 or 5 minutes. And it doesn't matter if a single pause isn't sufficient, what counts is how long the entire script takes to run.

Secondly, if you have some other javascript functionality built into the page, such as clicking on an element to do whatever, you'll find that it really has problems working while your pause loop is running.

A function that is executed as a result of setTimeout is different. It starts out with a brand new instance of the "browser timer" so you don't have this problem.

Why on earth would someone want to set a long pause?

The OP requested a pause for a reason, whatever that was and if it is going to cause problems with interactivity for users, then that is the problem of the programmer to decide on if they stop using pauses.

Only thing I can see a pause being used for is to either, pause an output to a display or to mimics the pause() / sleep() functions in a web browser emulator for another language.

Unless the OP comes clean with the true purpose or need for this scripting, we can be talking cross purposes all day long.

--> JavaScript Frameworks like JQuery, Angular, Node <--
... and please remember to wrap code with forum BBCode tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...