读书人

代码运行时间长会出错大家帮小弟我看

发布时间: 2012-08-11 20:50:31 作者: rapoo

代码运行时间长会出错,大家帮我看看怎么修改
procedure ControlCommReceiveData(Port:Integer; Buffer: Pointer; BufferLength: Integer);
var
tem, ErrMsg:String;
i : integer;
CurAlleyNO : integer;
CurAlley : TAlleyInfo;
CardId, StdId : string;
ComDataReault :integer;
begin
StdId := '';
try
try
if( not Assigned(zyCommData) ) then
Exit;
except
WriteEvent(DataM.LocalDBCnct, '判断zyComm是否为空出错');
end;

if( ReceivingData = TRUE ) then
begin
ReceivingData := TRUE;
WriteEvent(LocalDataM.LocalDBCnct, SysEvent_BusyRecvData, EventType_SysCmd);
Exit;
end;

ReceivingData := TRUE;
WriteEvent(DataM.LocalDBCnct, '接收数据开始');
try
tem := '';
for i:=0 to BufferLength-1 do
tem[i+1] := (Pchar(Buffer)+i)^; }
except
WriteEvent(DataM.LocalDBCnct, 'CCCCCCCCCCCCCCCC');
end;


try
if(zyCommData.GetData(tem, BufferLength)=-1) then//在下面
begin
ReceivingData := FALSE;
Exit;
end;
except
WriteEvent(DataM.LocalDBCnct, 'DDDDDDDDDDDDDDDDDD');
end;

try
tem := zyCommData.Data;
except
WriteEvent(DataM.LocalDBCnct, 'EEEEEEEEEEEEEEEEEEE');
end;
except
WriteEvent(LocalDataM.LocalDBCnct, '1002');
ReceivingData := FALSE;
exit;
end;
end;

function TSerialCommData.GetData(CommData:string; parDataLen:integer):Integer;
var
I : integer;
begin
Result := zyFailed;
try
try
if(CurLen=0) and (parDataLen>0) then
begin
CurLen := 0;
Data := '';
if( CommDataLenType = DLT_VarLen ) then
begin
DataLen := Integer(CommData[1]);
if(( DataLen <> 15 ) and ( DataLen<>20 ) and ( DataLen<>45 )) and (CommData[1] <> #3)then
begin
Exit;
end;
end;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'判断错误');
end;

for I:=1 to parDataLen Do
begin
try
Data := Data + char(CommData[I]);
except
WriteEvent(LocalDataM.LocalDBCnct, '拼接数据出错AAAA');
end;

try
Inc(CurLen);
if( curLen = DataLen ) then
begin
Result := zySuccess;
CurLen := 0;
break;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'拼接数据出错BBBB');
end;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'拼接数据出错');
end;
end;

[解决办法]
先说清楚什么错误,错误定位在哪一行
[解决办法]
问题不明确,无法确定错误

[解决办法]
同1意。
if( ReceivingData = TRUE ) then
begin
ReceivingData := TRUE;//句代起是用的。
WriteEvent(LocalDataM.LocalDBCnct, SysEvent_BusyRecvData, EventType_SysCmd);
Exit;
end;


[解决办法]

探讨

引用:

同1意。
if( ReceivingData = TRUE ) then
begin
ReceivingData := TRUE;//句代起是用的。
WriteEvent(LocalDataM.LocalDBCnct, SysEvent_BusyRecvData, EventType_SysCmd);
Exit;
end;


对对对……

读书人网 >.NET

热点推荐