Jump to content

Recommended Posts

Posted

Did you abandon your previous thread?

I'm assuming (not "suing"!) you mean JavaScript not POstScript here, too.

JavaScript has no sleep. The idea of blocking code in something built for the UI is an anathema. However, you can fake it.

The following works. It wraps the setTimeout in a promise, then uses await to block on it.

<html>
<head><title>Not a great general purpose programming environment</title></head>
<body>
<script>
ShowLine("You can't always get what you want.");

function sleep(ms = 0) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function ShowLine(input) {
  for (let i = 0; i < input.length; i++) {
    await sleep(250);
    document.write(input[i]);
  };
}
</script>
</body>
</html>

 

It seems to me you're really needing something else to do your programming with. (But you don't provide much detail to work with.)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.