I am trying to write a simple I2C interface program for Raspberry Pi but I am getting an error I don't understand...
function TRaspiI2C.ReadI2CBytes(addr: integer; count: integer; buf: array of byte): integer; var i: integer; begin try if count <> length(buf) then SetLength (buf, count); <== ERROR HERE! for i := 0 to count -1 do buf[i] := ReadI2CByte(addr + i); Result := count; except Result := 0; end; end; The error message states: rpii2ccomm.pas(158,7) Error: Type mismatch I have used setlength on dynamic byte arrays many times before and never gotten this strange error message. What am I doing wrong??? I have tried declaring buf as var in the call but it does not help. (addr: integer; count: integer; var buf: array of byte): integer; The same error happens. Must be something basic I have missed. Lazarus placed this at the top of the unit when I created it, if that matters: {$mode objfpc}{$H+} Using FPC 3.0.4 and Lazarus 2.0.6 on Raspbian Buster -- Bo Berglund Developer in Sweden -- _______________________________________________ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus