各位:
我写了个过程,大家帮我看看,其中
当Addr_int<17时没有问题,当Addr_int=17时就开始出现问题了,两种情有什么不同:
procedure Write_writedata;
var
  p:array[0..3] of byte;
  StrHex:string;
  inthex:integer;
  i:integer;
  SendStr:string;
begin
  SendStr:='';
  StrHex:=inttohex(trunc(Addr_int/2),2);
  inthex:=trunc(Addr_int/2);
  p[0]:=$57;
  p[1]:=$+upublic.strtohex(copy(StrHex,1,1));
  if system.Odd(Addr_int)=false  then
   p[2]:=$+(upublic.strtohex(copy(StrHex,2,1)))*16
    else
    begin
    p[2]:=$+(upublic.strtohex(copy(StrHex,2,1)))*16+8;
    form1.Memo1.Lines.Add(StrHex);
    end;
  p[3]:=$08;
  for i:=0 to 3 do
   SendStr:=SendStr+char(p[i]);
   myoutstr:=SendStr;
  form1.mscomm1.Output:=SendStr;//'50 00 88 08';
end;

解决方案 »

  1.   

    我本意是这样子的:
    if addr_int=0 then sendstr:=50 00 00 08
    if addr_int=1 then sendstr:=50 00 08 08if addr_int=2 then sendstr:=50 00 10 08
    if addr_int=3 then sendstr:=50 00 18 08
    依此下去到if Addr_int=17 then sendstr:=50 00 88 08
    可是它确=50 00 3F不知是什么问题
      

  2.   

    在我这里 p = 50 00 88 08; 用SendStr,m查看也是 $57 $00 $88 $08