On 11/02/2014 03:54 PM, Xiangrong Fang wrote:
Hi All,

...

Also, I usually use pointer to pass block of memory to functions. How do I implement a function with the following signature:

procedure MyProc(var Buf; Len: Integer):

I mean, how to handle "var Buf" inside the procedure body?
You can take the address of the Buf variable by using @Buf. For example:

procedure MyProc(var Buf; Len: Integer);
var
  I: Integer;
  P: PByte;
begin
  P := @Buf;
  for I := 0 to Len - 1 do
    (P+I)^ := 0;
end;

Nikolay
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to