function getCrc(s:shortstring):String;
var
 len,i:integer;
 CRC16:word;
begin
 crc16:=0;
 len:=length(s);
 for i:=1 to len do
  begin
   if (s[i]<>'') and (s[i]<>'|') then
    mybytecrc(ord(s[i]),crc16);
  end;
   Result:=inttohex(crc16,4);
end;
procedure MyByteCrc(data:byte;var crc:word);
var
 i:byte;
begin
 for i:=0 to 7 do
  begin
   if ((data and $01) xor (crc and $0001) <> 0) then
    begin
     crc:=crc shr 1;
     crc:=crc xor $A001;
    end
   else crc:=crc shr 1;
   data:=data shr 1;
  end;
end;

解决方案 »

  1.   

    function getCrc(s:shortstringvar
    locat lnlen,lni,(CRC16:word;这个不知道在vfp中用什么表示)
    crc16:=0;
    len:=length(s);
    for i:=1 to len 
    (
       if (s[i]<>'') and (s[i]<>'|') 
        mybytecrc(ord(s[i]),crc16);
      endif;   Result:=inttohex(crc16,4);
    )
    在项目中新建prg
    不记得在vfp中 byte,word怎么表示
    byte 位,word,16进制数MyByteCrc(data:byte;var crc:word);
    LPARAMETERS tnbyte,tccrc  //
    locat i  for i:=0 to 7 
    (
      if ((data and $01) xor (crc and $0001) <> 0) 
         crc:=crc shr 1  **向右移位1位
         crc:=crc xor $A001  ** 异或  
      else 
         crc:=crc shr 1;
         data:=data shr 1;
      endif;
    )
      

  2.   

    前面写错了一此,重写一次,改正一些错误.function getCrc(s:shortstringvar
    locat lnlen,lni,(CRC16:word;16进制数,这个不知道在vfp中用什么表示,好象可以用#表示,#3表示16进制中的3)
    crc16:=0;
    len:=length(s);
    for i:=1 to len 
       if (s[i]<>'') and (s[i]<>'|') 
        mybytecrc(ord(s[i]),crc16)
      endif;   RETURN inttohex(crc16,4)//IntToHex是把一个10进制的数转换成16进制的数.
    endfor
    在项目中新建prg
    不记得在vfp中 byte,word怎么表示
    byte 位,word,16进制数MyByteCrc(data:byte;var crc:word);
    LPARAMETERS tnbyte,tccrc  //
    locat i 
     for i:=0 to 7 
      if ((data and $01) xor (crc and $0001) <> 0) 
         crc:=crc shr 1  **向右移位1位
         crc:=crc xor $A001  ** 异或  
      else 
         crc:=crc shr 1;
         data:=data shr 1;
      endif
     endfor
      

  3.   

    delphi 中 有:= 相当于vfp中的 =
    就是赋值的意思
    比如:crc16:=0 ;在vfp中是
    crc16 = 0 你自己再改改吧,
      

  4.   

    16进制和byte类型我也不知道怎样在vfp中表示!!