For Example:
var redata:variant;
redate:byte;
result:string;
recount:integer;
mode:string;
if (fMScomm.portopen) then
begin
if mode='Text' then
begin
fMScomm.inputmode:=cominputmodetext;
result:fMScomm.input;
end
else
begin
result:=''
recount:=fMScomm.inbuffercount;
redata:=VarArrayCreate([0,127],varbyte);
redata:=fMScomm.input;
for i:=0 to recount-1 do
begin
redate:=redata;
result:=result+chr(redate);
end;
fMScomm.inputmode:=cominputmodetext;
end;
end;