-6

I am trying to pass pointer to data into function. But I am getting error Incompatible types: 'Array' and 'TBytes'. I cannot find out how to fix it.

type TBytes = array of byte;
type PTBytes = ^TBytes;

procedure Dictionary.WriteData(Data: PTBytes);
begin
  try
    DataStream.Write(Data[0], sec[sid].grp[grp].META.dataLength);
  finally
  end;
end;

Previously I tried

pData: ^TBytes;
PData := Data^;

Finally I call

writeData( data);

But it generates error Pointer type required

Edit

I have replaced the procedure appendData to writeData. It is easer now.

6
  • 2
    It would be more idiomatic to name the pointer type PBytes. (More generally, given a type TMyThing, we often define PMyThing = ^TMyThing.) Aug 18, 2018 at 13:51
  • 2
    But you don't use pData at all. It would better to describe real problem.
    – MBo
    Aug 18, 2018 at 14:04
  • A variable of TBytes is a pointer in itself.
    – LU RD
    Aug 18, 2018 at 15:49
  • 2
    I think you should at least edit your code (and the answer you have accepted) so that they are less nonsensical (making no use of the input data and uselessly operating on a local variable). Meanwhile -1 and VTC.
    – MartynA
    Aug 18, 2018 at 16:05
  • @MartynA: The question updated. Hopefully it makes more sense now.
    – John Boe
    Aug 24, 2018 at 19:50

1 Answer 1

0

Because IVO GELOV did not updated his code and/or did not removed his answer, I am adding my current code, which I am using.

type TBytes = array of byte;

procedure Dictionary.WriteData(var Data: TBytes);

begin
  try
    DataStream.Write(Data[0], sec[sid].grp[grp].META.dataLength);
  finally
  end;
end;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.