{
Read line from pipe with CR terminator and LF ignore.
}
function Pipe_Readln(pipe:Integer; var DataLine,TempBuff:String):Boolean;
const MaxLeng = 16384;
var i,p,L:Integer;
begin
 DataLine:='';
 Pipe_Readln:=false;
 if pipe_pid(pipe)<>0 then begin
  L:=Length(TempBuff);
  p:=pos(chr(13),TempBuff);
  if p=0 then begin
   if L<MaxLeng then TempBuff:=TempBuff+pipe_recv(pipe,MaxLeng-L);
   L:=Length(TempBuff);
  end;
  if L>0 then begin
   if p=0 then p:=Pos(chr(13),TempBuff);
   if p>0 then begin
    Pipe_Readln:=true;
    i:=1;
    while (i<p) and (TempBuff[i]=chr(10)) do i:=i+1;
    if i<p then DataLine:=Copy(TempBuff,i,p-i);
    i:=p+1;
    while i<=L do begin
     if TempBuff[i]=chr(10) then p:=i else i:=L;
     i:=i+1;
    end;
    TempBuff:=Copy(TempBuff,p+1);
   end else begin
    if Length(TempBuff)>=MaxLeng then begin
     Trouble('Received line is too long!');
     TempBuff:='';
    end;
   end;
  end;
 end;
end;
