[fpc-pascal]SelectText problem for stdin (Linux unit)

Georgi Georgiev skelet_bg at yahoo.com
Tue Jul 23 15:36:24 CEST 2002


I'm traing to test if there is some input
bytes ready in stdin. When i try this with normal
file, all is ok - SelectText function from Linux unit
give me n>0 if any character is ready.

When i try with file 'input', SelectText give me 0
until 2 lines are entered. How to go round this
without using old and more low-level libs like crt ?

------- test program -------

program test;
uses Linux;

var n:longint; w:char; TV:TimeVal;

begin
 TV.sec:=0; TV.usec:=0;
 repeat
  n:=SelectText(input, at TV);
  if n>0 then begin
    read(w); write(w);
    write('[',n,']');
  end;
 until eof(input);
end.

--------- test results: ----------

1234
abcd
1[1]2[1]3[1]4[1]
[1]ABCD
a[1]b[1]c[1]d[1]
[1]

--------- must be: ---------------

1234
1[1]2[1]3[1]4[1]
[1]abcd
a[1]b[1]c[1]d[1]
[1]ABCD

----------------------------------

=====
Skelet
====== http://skelet.hit.bg

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com




More information about the fpc-pascal mailing list