Hi! Is there a way to read from standard input with a nonblocking call? That is, the call should return even if there is no data..
Or eventually a way to see if there is data avaiable on standard input..
Thanks
Hi! Is there a way to read from standard input with a nonblocking call? That is, the call should return even if there is no data..
Or eventually a way to see if there is data avaiable on standard input..
Thanks
If you save your data in a proprietary format, the owner of the format owns your data.
<br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>
You might be able to poll the keyboard input buffers. This would be nonblocking
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
ok.. but how do you do it?
also, is this way cross platform?
thanks
If you save your data in a proprietary format, the owner of the format owns your data.
<br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>
[pascal]function readKeydownCount: integer;
var a: array[0..63] of TInputRecord;
vb: cardinal;
I: Integer;
t: TKeyEventRecord;
begin
result := 0;
PeekConsoleInput(GetStdHandle(STD_INPUT_HANDLE), a[0], 64, vb);
for I := 0 to vb - 1 do
begin
if (a[i].EventType and KEY_EVENT) = KEY_EVENT then
begin
t := a[i].Event.KeyEvent;
if t.bKeyDown then
inc(result);
end;
end;
end;[/pascal]
Sorry, I don't know any crossplatform way of doing it except for reading some INT 0x10 stuff
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Pure standard input, or do you know it is always the keyboard?
(The first typically for cgi's, the second for console programs)
If the latter, have a look at the "keyboard" unit that is used by the textmode IDE. The textmode IDE needs such functionality too, since it is eventdriven.
Bookmarks