How initialaize TPoint array: Poly: array [0..2] of TPoint = ( (1,1), (2,2), (3,3) ); //not compile

Hi Experts,

how to initialize a TPoint Array, like:
   Poly: array [0..2] of TPoint = ( (1,1), (2,2), (3,3) ); //this won't compile

Sincerely,
odissey1
LVL 2
odissey1Asked:
Who is Participating?
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
Array of Tpoint is almost like Array of record, so you have to assign the values for members of record.

 Poly: array [0..2] of TPoint = ( (x:1;y:1), (x:2;y:2), (x:3;y:3) );
0
 
twinsoftCommented:
Hi,
  something like this will do the work (workaround).

procedure TForm1.Button1Click(Sender: TObject);
const
 v: array [0..2, 0..1] of Integer = ((1, 2), (1, 1), (1, 1));
var
 p: array [0..2] of TPoint;
 i: Integer;
begin
 for i := low(p) to high(p) do
  p[i] := Point(v[i][0], v[i][1]);
end;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.