我在通信时把数据读到了一个buf里,现在希望读回到memo显示,但是不成功?请教
以下是接收的程序
const
len =100;
var
Buf:Array[1..Len]of byte;
iCount,ret,ret1,ret2,ret3,i:Integer;
str:array of String;
begin
fillchar(buf,len,0);
ret:=sio_read(port,@buf,len);
ret1:=ret-1;
iCount := 1; while (Buf[iCount] <>$AD)and(iCount < ret - 2) do//判断接收到的数
//据的开始和结束
Inc(iCount);
if (Buf[iCount] = $AD)and(Buf[iCount+ret1] = $EE) then
begin
with Form1 do
begin
ret2:=icount+1;
ret3:=ret-2;
for i:=ret2 to ret3 do
begin
str:=str+buf[i];//这里出错了,但不知道怎么改?
end;
memo1.lines.append('str');
end;
end;
以下是接收的程序
const
len =100;
var
Buf:Array[1..Len]of byte;
iCount,ret,ret1,ret2,ret3,i:Integer;
str:array of String;
begin
fillchar(buf,len,0);
ret:=sio_read(port,@buf,len);
ret1:=ret-1;
iCount := 1; while (Buf[iCount] <>$AD)and(iCount < ret - 2) do//判断接收到的数
//据的开始和结束
Inc(iCount);
if (Buf[iCount] = $AD)and(Buf[iCount+ret1] = $EE) then
begin
with Form1 do
begin
ret2:=icount+1;
ret3:=ret-2;
for i:=ret2 to ret3 do
begin
str:=str+buf[i];//这里出错了,但不知道怎么改?
end;
memo1.lines.append('str');
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货