南
南宫吹云
Unregistered / Unconfirmed
GUEST, unregistred user!
byte类型为什么不能进行整数的运算:
var
rbuf:byte;
当rbuf mod 16>8时 rbuf div 16 或者时出错。
我的程序是检测串口发送的数据,并更新数据库:
procedure TForm1.Comm1ReceiveData(Sender: TObject
Buffer: Pointer;
BufferLength: Word);
var
s:string;
i:integer;
begin
move(buffer^,pchar(@rbuf)^,1)
// bufferlength)
with table1 do
begin
//showmessage(inttohex(rbuf,2));
if (rbuf mod 16)>8 then exit
//正好我用不到(rbuf mod 16)>8的情况,当去掉此句时出错
if (rbuf mod 16)=8 then
begin
if locate('jpk;djh',vararrayof([jpk[rbuf div 16],djh[rbuf div 16]]),[lopartialkey]) then
begin
edit;
fieldbyname('an').value:=false;
fieldbyname('shj').asinteger:=9999;
post;
end;
close;
open;
exit;
end;
if locate('jpk;djh',vararrayof([(rbuf div 16)+1,rbuf mod 16+1]),[lopartialkey]) then
begin
jpk[rbuf div 16]:=fieldbyname('jpk').asinteger;
djh[rbuf div 16]:=fieldbyname('djh').asinteger;
s:=formatdatetime('hhmmss',time);
i:=strtoint(copy(s,1,2))*60+strtoint(copy(s,3,2));
edit;
fieldbyname('an').value:=true;
fieldbyname('shj').asinteger:=i;
post;
close;
open;
end;
end;
end;
是这个问题,麻烦各位帮忙看一下。
var
rbuf:byte;
当rbuf mod 16>8时 rbuf div 16 或者时出错。
我的程序是检测串口发送的数据,并更新数据库:
procedure TForm1.Comm1ReceiveData(Sender: TObject
Buffer: Pointer;
BufferLength: Word);
var
s:string;
i:integer;
begin
move(buffer^,pchar(@rbuf)^,1)
// bufferlength)
with table1 do
begin
//showmessage(inttohex(rbuf,2));
if (rbuf mod 16)>8 then exit
//正好我用不到(rbuf mod 16)>8的情况,当去掉此句时出错
if (rbuf mod 16)=8 then
begin
if locate('jpk;djh',vararrayof([jpk[rbuf div 16],djh[rbuf div 16]]),[lopartialkey]) then
begin
edit;
fieldbyname('an').value:=false;
fieldbyname('shj').asinteger:=9999;
post;
end;
close;
open;
exit;
end;
if locate('jpk;djh',vararrayof([(rbuf div 16)+1,rbuf mod 16+1]),[lopartialkey]) then
begin
jpk[rbuf div 16]:=fieldbyname('jpk').asinteger;
djh[rbuf div 16]:=fieldbyname('djh').asinteger;
s:=formatdatetime('hhmmss',time);
i:=strtoint(copy(s,1,2))*60+strtoint(copy(s,3,2));
edit;
fieldbyname('an').value:=true;
fieldbyname('shj').asinteger:=i;
post;
close;
open;
end;
end;
end;
是这个问题,麻烦各位帮忙看一下。