G
gm88
Unregistered / Unconfirmed
GUEST, unregistred user!
unit UCRC;<br>interface<br><br>type TCRC=class<br> public<br> Value:integer;<br> constructor Create;<br> procedure Init;<br> procedure Update(const data: array of byte;const offset,size:integer);overload;<br> procedure Update(const data: array of byte);overload;<br> procedure UpdateByte(const b:integer);<br> function GetDigest:integer;<br> end;<br><br>implementation<br><br>var Table: array [0..255] of integer;<br><br>constructor TCRC.Create;<br>begin<br>Value:=-1;<br>end;<br><br>procedure TCRC.Init;<br>begin<br>Value:=-1;<br>end;<br><br>procedure TCRC.Update(const data: array of byte;const offset,size:integer);<br>var i:integer;<br>begin<br>for i := 0 to size-1 do<br> value := Table[(value xor data[offset + i]) and $FF] xor (value shr 8);<br>end;<br><br>procedure TCRC.Update(const data: array of byte);<br>var size:integer;<br> i:integer;<br>begin<br>size := length(data);<br>for i := 0 to size - 1 do<br> value := Table[(value xor data) and $FF] xor (value shr 8);<br>end;<br><br>procedure TCRC.UpdateByte(const b:integer);<br>begin<br>value := Table[(value xor b) and $FF] xor (value shr 8);<br>end;<br><br>function TCRC.GetDigest:integer;<br>begin<br>result:=value xor (-1);<br>end;<br><br>procedure InitCRC;<br>var i,j,r:integer;<br>begin<br>for i := 0 to 255 do begin<br> r := i;<br> for j := 0 to 7 do begin<br> if ((r and 1) <> 0) then<br> r := (r shr 1) xor integer($EDB88320)<br> else r := r shr 1;<br> end;<br> Table := r;<br> end;<br>end;<br><br>initialization<br>InitCRC;<br><br>end.<br>以上是我在d3里面编辑的,出现了以下的错误:<br>UCRC.pas(9):Field definition not allowed after method or properties.<br>UCRC.pas(10):Unknown directive 'Update'.<br>UCRC.pas(10):'['expected but 'OF' found.<br>UCRC.pas(10):'='expected but ';' found.<br>UCRC.pas(13):'IMPLEMENTATION'expected but ';' found.<br>UCRC.pas(15):'.'expected but 'IMPLEMENTATION' found..<br>UCRC.pas(7):Unsatisfied forward or external declaration 'TCRC.Create'.<br>UCRC.pas(8):Unsatisfied forward or external declaration 'TCRC.Init'.<br>UCRC.pas(9):Unsatisfied forward or external declaration 'TCRC.Update'.<br>UCRC.pas(11):Unsatisfied forward or external declaration 'UpdateByte'.<br>UCRC.pas(12):Unsatisfied forward or external declaration 'GetDigest'.<br>有哪位大侠看出端儿了给指教下,谢谢了。