Game Development Community

hwo do true consoles work?

by Matthew Shapiro · in Technical Issues · 02/03/2002 (6:40 am) · 5 replies

Dos like consoles like dedicated servers.. How does the entering text work? heres what i mean its' kinda hard to explain: Everything is done basically in a while loop that runs untill the program says it's done. Now text scrolls as it comes in, which is easyily done with printf or cout. But when i try to input data and type something with cin the program obviously pauses inside the loop, therefore mkaing the calculation of data only happen if you constantly press enter. So how do you:

A)Allow the entering of commands and such wihtout pausing the loop like consoles do?

b) keep the text that you are entering at the bottom of the screen while the text your displaying scrolls on top of that?

Thanks in advance for your hlep. FYI I'm a novice-intermediate programmer.

#1
02/03/2002 (8:02 am)
You will want to make your read calls non-block. That way it won't block the whole application when there is no data to read.
#2
02/03/2002 (1:11 pm)
How would i do that with cin or would i use a different function?
#3
02/03/2002 (1:28 pm)
Wouldn't putting the console in its own Thread fix the problem too or does it suspend all threads when waiting?

-Tim aka Spock
#4
02/03/2002 (1:32 pm)
It would block the whole program because the thread would block all of the other threads when it was blocked by the read().
#5
02/03/2002 (3:19 pm)
Ok i found out how i could do the non-blocking input using windows messages but i can't figure out how to put all the output text above the first line and use the first line for what the person is entering.... I was told that printf can do this but I odn't see how on msdn.. any ideas?