Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-15 Thread tcoq
thank you Martin, I obviously failed somewhere. I did try FILE_FLAG_OVERLAPPED and everything attached to it, but the input is already opened, so i get an error. I'll try somewhat later when real life gives me a new break. Off for now. Thierry - Mail Original - De: Martin Schreiber

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-15 Thread Martin Schreiber
On 12/15/2011 03:31 PM, tcoq wrote: I obviously failed somewhere. I did try FILE_FLAG_OVERLAPPED and everything attached to it, but the input is already opened, so i get an error. IIRC I experienced the same with pipes on windows. So I used threads which works on win95+. Martin

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-10 Thread tcoq
Thanks Michael, I also tried with a 20 ms delay. No success. Still investigating. - Mail Original - De: Michael Van Canneyt mich...@freepascal.org À: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Envoyé: Vendredi 9 Décembre 2011 22h51:01 GMT +01:00 Amsterdam / Berlin /

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-10 Thread tcoq
Chad, Thank you very much. I will try your approach, as I'm interested in the piping. I also did some experimenting with SetConsoleMode, and also with SetFileAttributes, and with ReadFileEx. But no answer there. Still blocks. Best regards, Thierry - Mail Original - De: Chad Berchek

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-10 Thread Martin Schreiber
On 12/10/2011 02:58 PM, tcoq wrote: Chad, Thank you very much. I will try your approach, as I'm interested in the piping. I also did some experimenting with SetConsoleMode, and also with SetFileAttributes, and with ReadFileEx. But no answer there. Still blocks. IIRC non blocking pipes

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread tcoq
Thanks Michael, I'll try that! Thierry - Mail Original - De: Michael Van Canneyt mich...@freepascal.org À: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Envoyé: Vendredi 9 Décembre 2011 16h57:47 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re:

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said: Is there a way to ask whether the input stream is not empty, without waiting and without using threads/processes? And, in addition, is there an OS-independent way (linux, windows)? something like: var inputStream: THandleStream;

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread tcoq
On windows, I did not find WaitForSingleObject, which is actually going to wait for the file. However I found ReadFileEx in the Windows API, which is an asynchronous read on the file. I'll try using that. - Mail Original - De: Michael Van Canneyt mich...@freepascal.org À: FPC-Pascal

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Jorge Aldo G. de F. Junior
Thats an old problem on the way TStream was implemented. I for one needed to know the result size of a uncompress stream (IE.: i have a compressed stream and want to know in advance how many bytes the uncompress method would yield). The stream system is currently a mess, sometimes you can know

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Michael Van Canneyt
On Fri, 9 Dec 2011, Jorge Aldo G. de F. Junior wrote: Thats an old problem on the way TStream was implemented. I for one needed to know the result size of a uncompress stream (IE.: i have a compressed stream and want to know in advance how many bytes the uncompress method would yield).

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Jorge Aldo G. de F. Junior
I think the main problem is that TStream tries to abstract two kinds of resources : Character based resources and block based resources. The end result is that it is no good for neither of the two cases. 2011/12/9 Michael Van Canneyt mich...@freepascal.org: On Fri, 9 Dec 2011, Jorge Aldo G.

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread tcoq
I have found and tried WaitForSingleObject, using the following syntax: ThereIsACharacterToRead := WaitForSingleObject(StdInputHandle,0) = 0; While ThereIsACharacterToRead do begin aByte := InputStream.ReadByte; ThereIsACharacterToRead := WaitForSingleObject(StdInputHandle,0) = 0; end;

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Michael Van Canneyt
On Fri, 9 Dec 2011, Jorge Aldo G. de F. Junior wrote: I think the main problem is that TStream tries to abstract two kinds of resources : Character based resources and block based resources. The end result is that it is no good for neither of the two cases. You are not forced to use it :-)

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Michael Van Canneyt
On Fri, 9 Dec 2011, tcoq wrote: I have found and tried WaitForSingleObject, using the following syntax: ThereIsACharacterToRead := WaitForSingleObject(StdInputHandle,0) = 0; While ThereIsACharacterToRead do begin aByte := InputStream.ReadByte; ThereIsACharacterToRead :=

Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Chad Berchek
On 12/9/2011 9:44 AM, tcoq wrote: Hello, I'm trying to poll the input stream to see whether there is a new character available, without blocking my software. Maybe TInputPipeStream.NumBytesAvailable can help. You can find it in the documentation of the Pipes unit. I tried an experiment to