My Delphi file has no complier switches on or off written in the file
Uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, System.Types;
System.Types is suppose to contain Rect as by Delphi documentation
my compiler says it complies with TRect in the functions header
but I cannot install ‘Result := Rect(0, 0, 0, 0);’ in the same function
other things like Double( Ptr^) - the word Double does not compile yet Double is in the same function s header
and the same with Int64 will not work ether
and then currency and integer all work perfectly
What is going on?
Blockquote System.Types is suppose to contain Rect as by Delphi documentation
Where are you looking?
There is TRect. → System.Types - RAD Studio API Documentation
TRect = record
private
function GetWidth : Integer;
function GetHeight: Integer;
function GetSize : TSize;
procedure SetWidth (const Value: Integer);
procedure SetHeight(const Value: Integer);
procedure SetSize (const Value: TSize);
function GetLocation: TPoint;
public
constructor Create(const Origin: TPoint); overload; // empty rect at given origin
constructor Create(const Origin: TPoint; Width, Height: Integer); overload; // at TPoint of origin with width and height
constructor Create(const Left, Top, Right, Bottom: Integer); overload; // at Left, Top, Right, and Bottom
constructor Create(const P1, P2: TPoint; Normalize: Boolean = False); overload; // with corners specified by p1 and p2
constructor Create(const R: TRect; Normalize: Boolean = False); overload;
Double is a Type …
var
velocity : double;
If you write Double( Ptr^), then you are dereferencing a pointer to get the Type Value it points to … then casting it to Type Double, which may or may not make sense … and either way might be a code smell.
var
x : integer;
px : ^integer;
d : double;
begin
x := 1;
px := @x;
d := Double( px^ ); // d = 1.0
end.
What warnings hints and errors is the compiler giving you?
i would have assumed you couldn’t cast from Int64 to Double … but I tried it and you can. ¯\(ツ)/¯
in the end I believe I answered it my self
type
PDouble = ^Double;
making things into a pointer like above I can allocate memory and use pointers to load and read memory