I'm having some trouble with the syntax of Delphi.
I have a record:
type
TMyType = record
....
end;
and a procedure:
procedure Foo(bar:Integer);
var
ptr : ^TMyType
begin
ptr := bar //how to do this?
end;
How do I properly cast an integer to a pointer of TMyType?
Like this:
type
PMyType = ^TMyType;
procedure Foo(bar: Integer);
var
ptr: PMyType;
begin
ptr := PMyType(bar);
end;
You must cast it explicitely with the new type:
type PMyType = ^TMyType;
ptr := PMyType(bar);
or
ptr := pointer(bar);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With