Author: Inmann Werner
Date: 12:58:50 11/03/99
Go up one level in this thread
On November 03, 1999 at 14:57:55, Alexander Kure wrote:
>On November 03, 1999 at 06:11:19, Inmann Werner wrote:
>
>>Hello to all, "understanding" NT.
>>
>>I am getting crazy in trying my program to get run under NT!!!!
>>Never done NT and not knowing it anyway.
>>
>>I isolated the problem (hope so)
>>
>>I read incoming "keystrokes" (Winboard) after detecting that there are
>>keystrokes in a loop with
>>
>>getkey(charac)
>>int *charac;
>>{
>>int rr;
>>char bu[81];
>>
>>NM2:
>>rr=read(fileno(stdin),&bu,1);
>>if (rr<=0) goto NM2;
>>*charac=bu[0];
>>return(0);
>>}
>>
>>ok, a litte "crazy" code, but nice working with win95/98 and Linux.
>>But with NT, if do the loop calling getkey, the first character of each text is
>>always a "W"!!!!!!!
>>
>>Example debug File
>>WO or
>>W2E4
>>.....
>>
>>to ask, if keystrokes are available I use the "simple" routine from crafty.
>>it should not change anything?!?!?
>>
>>
>>checkkey()
>>{
>>static int init = 0, pipe;
>>static HANDLE inh;
>>DWORD dw;
>>
>> if (!init)
>> {
>> init = 1;
>> inh = GetStdHandle(STD_INPUT_HANDLE);
>> pipe = !GetConsoleMode(inh, &dw);
>> if (!pipe)
>> {
>> SetConsoleMode(inh, dw & ~(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT));
>> FlushConsoleInputBuffer(inh);
>> }
>> }
>>
>> if (pipe)
>> {
>> if (!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL))
>> {
>> return 0;
>> }
>> return(dw);
>> }else
>> {
>> GetNumberOfConsoleInputEvents(inh, &dw);
>> return dw <= 1 ? 0 : dw;
>> }
>> return(0);
>>}
>>
>>*************************
>>
>>any suggestion??
>>(I use Watcom C Compiler)
>>
>>Werner
>
>Hi Werner,
>
>Seems you are mixing WIN32 API calls (GetConsoleMode(),
>FlushConsoleInputBuffer(), ...) with low level calls from the C standard library
>(read()). Wonder how this worked under Linux ;-)
>Maybe you can try ReadConsoleInput() for retrieving data from stdin.
>
>Greetings Alex
>
*********************
The program is a dos program, some lines rewritten for windows, compiled for
win95, and wonder, it works....
how is the full syntax of ReadConsoleInput() and could it also work under
Win95,Win98,Linux and then also with the winboard stdin thing?
>PS: goto????????
>
>>NM2:
>>rr=read(fileno(stdin),&bu,1);
>>if (rr<=0) goto NM2;
>
>better style would be
>
>while (read(fileno(stdin),&bu,1) <= 0);
>...
Yeah.
I wrote "crazy code" and that is it.....
Ugly,fast written, and as it worked never looked again at it.....
(Yes, I have a chaotic programming style)
Thanks a lot
Werner
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.