Posted by Rick on December 22, 2007
In Reply to delphi pascal posted by clive on December
: Hi I'm a beginner to programming so if you can't help thats fine. I am trying to make a console application so that when i press and hold a key it counts until i release it then outputs the total. I can get it too count if i repeatedly press the key but im not sure how to do it so i can keep the key pressed until im finished and it will continue to count. Please remember i am VERY VERY new at this so i will need simple help lol Thanks in advance
I assume that you mean something like this:
N := 0;
N := N + 1;
This won't work as intended, because your console program only receives the keyboard input after the ENTER key is pressed. If you just press and release keys without pressing ENTER, the program sits waiting indefinitely *before* the Read(C) and no counting occurs.
On the other hand, this is very easy with a Delphi application for Windows... so why make pre-historic console applications, while Delphi was meant for Windowss? ;)