function readcom: string;
var temp: string;
inbuff: array[0..10240] of char;
nbytesread, dwerror: longword;
cs: tcomstat;
begin
clearcommerror(hcomm, dwerror, @cs);
if cs.cbInQue > sizeof(inbuff) then
begin
purgecomm(hcomm, purge_rxclear);
exit;
end;
readfile(hcomm, inbuff, cs.cbInQue, nbytesread, nil);
temp := copy(inbuff, 1, cs.cbInQue);
result := temp;
end ;
memo1.lines.add(readCom);