Re: [Lazarus] Why is setlength not allowed?

2019-11-16 Thread Bo Berglund via lazarus
On Sat, 16 Nov 2019 11:50:45 +0100 (CET), Michael Van Canneyt via lazarus wrote: >> I guess that the reason is that fpIoCtrl expects a pointer type >> variable so the typecast is done... Is there no alternative? > >The warning seems correct. I suspect Pointer(iDevAddr) is probably wrong. >Maybe

Re: [Lazarus] Why is setlength not allowed?

2019-11-16 Thread Michael Van Canneyt via lazarus
On Sat, 16 Nov 2019, Bo Berglund via lazarus wrote: function InitI2cDevice(devpath: String; iDevAddr: Cint; var hInst: Integer): Integer; var iio : integer; begin try hInst := fpopen(devpath, O_RDWR); //Open the I2C bus in Read/Write mode iio := FpIOCtl(hInst, I2C

Re: [Lazarus] Why is setlength not allowed?

2019-11-16 Thread Bo Berglund via lazarus
On Sat, 16 Nov 2019 09:20:28 +0100 (CET), Michael Van Canneyt via lazarus wrote: > > >On Sat, 16 Nov 2019, Bo Berglund via lazarus wrote: > >> 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.ReadI2CBy

Re: [Lazarus] Why is setlength not allowed?

2019-11-16 Thread Michael Van Canneyt via lazarus
On Sat, 16 Nov 2019, Bo Berglund via lazarus wrote: 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

[Lazarus] Why is setlength not allowed?

2019-11-15 Thread Bo Berglund via lazarus
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, cou