i/o simultaneously

i have created a loop for displaying the first 99 natural numbers and have also used delay(1000); between each output.
However i want that if the user enters spacebar during the execution of the loop , then the loop must break.
so the problem is that how can i ask for a value from the user while continuing the execution ??
Basically, you can't. I mean, you can't both wait and not-wait.

If you are using an operating system you could crete two tasks: One that does the output of numbers and then does a 1000-ms timed-wait for a semaphore. This semaphore is then given by an input task if a space character is input. By checking the return value of the semaphore wait-operation you could determine if you got out of the wait due to timeout or a space.

Did that make sense?

/Troels
You could get the keyboard status (if the spacebar is pressed)
i havent understood a single thing.
Either you thread it, or as Bazzy said. You can get the keyboard status for the spacebar and check if it's currently pressed.
Topic archived. No new replies allowed.