“异或xor”是什么意思?ord是什么意思?inttohex是什么意思?
copy(CrcStr,length(CrcStr )-1,2)是取的哪一段?
能帮我解释一下下面的程序吗?假设cscstr=‘$$1,12345*08’;
 if copy(CrcStr,1,3)='$$1' then
    begin
      for i := 2 to length(CrcStr)-3 do
        begin
          crctemp := crctemp xor ord(CrcStr[i]);
        end;
if copy(CrcStr,length(CrcStr )-1,2) = inttohex(crctemp,2) then
        begin
……

解决方案 »

  1.   

    Delphi的帮助目录下的Object Pascal Refernce中有解释。你去看看
      

  2.   

    inttohex是将整形数转换成2位的十六进制的字符。
      

  3.   

    异或xor”是 : 一种位运算,运算规则:同为0,不同为1
    ord是       :返回序数类的序数
    inttohex是  :10进制转16进制
    copy(CrcStr,length(CrcStr )-1,2)是: 右取2位能帮我解释一下下面的程序吗?假设cscstr=‘$$1,12345*08’;
     if copy(CrcStr,1,3)='$$1' then   // 左取3位,判断是否:$$1
        begin
          for i := 2 to length(CrcStr)-3 do
            begin
              crctemp := crctemp xor ord(CrcStr[i]);  // 从CrcStr字串中取出第每个字符的序号与crctemp的内容异或,并将结果保存于crctemp中,用于与CrcStr的下一字符进行异或
            end;
    // 右取CrcStr的右两个字符,与crctemp(转进十六进制)比较
    if copy(CrcStr,length(CrcStr )-1,2) = inttohex(crctemp,2) then
            begin
    ……