Results 1 to 5 of 5

Thread: Nonblocking standard input

  1. #1

    Nonblocking standard input

    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>

  2. #2

    Nonblocking standard input

    You might be able to poll the keyboard input buffers. This would be nonblocking
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    Nonblocking standard input

    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>

  4. #4

    Nonblocking standard input

    [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

  5. #5

    Nonblocking standard input

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •