* * *

Author Topic: Polygon points (Solved)  (Read 553 times)

Degibbo

  • New member
  • *
  • Posts: 23
Polygon points (Solved)
« on: August 01, 2017, 09:59:54 am »
G'day all,
This is probably not the best place to post this, so I will take suggestions
(don't want to upset anybody).

Drawing a polygon on a canvas, the code line is:
Polygon([Point(a,b), point(b,c) etc ]);
The compiler expresses that after the 1st variable (a) that ")" was expected but "," found.
Many examples that I have looked at, tend to be equivalent to my line of code.

Is there a trick to using Point() other than creating an array?  The compile fails even with
a simple reference to Point such as (for example):

Var
  Q :  TPoint;
  a,b : integer;

  a := 1;
  b := 2;
  Q := Point(a,b);  same problem.
 
Any suggestions?  (OBTW it worked OK in Delphi)

Thanks,
DG
« Last Edit: August 09, 2017, 05:45:47 am by Degibbo »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5644
Re: Polygon points
« Reply #1 on: August 01, 2017, 10:02:26 am »
Point is an old windows macro, and probably part of the Windows unit, and as such not part of the portable subset of the VCL.

Might work with lazarus too if you include unit windows.

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Polygon points
« Reply #2 on: August 01, 2017, 10:07:53 am »
It should work with lclintf instead of windows. If it doesn't, there's a simple solution.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

GetMem

  • Hero Member
  • *****
  • Posts: 2249
Re: Polygon points
« Reply #3 on: August 01, 2017, 10:09:23 am »
It works fine with fpc 3.02. Point is declared in unit classes:
Code: Pascal  [Select]
  1. function Point(AX, AY: Integer): TPoint;
  2. begin
  3.   with Result do
  4.   begin
  5.     X := AX;
  6.     Y := AY;
  7.   end;
  8. end;  

The following code also works:
Code: Pascal  [Select]
  1. Form1.Canvas.Polygon([Point(2,2), Point(120, 140), Point(2, 75)]);

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Polygon points
« Reply #4 on: August 01, 2017, 10:13:17 am »
It works fine with fpc 3.02. Point is declared in unit classes:
It is also declared in unit types which in this case is the correct one.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

GetMem

  • Hero Member
  • *****
  • Posts: 2249
Re: Polygon points
« Reply #5 on: August 01, 2017, 10:25:23 am »
The issue only occurs when windows is in the uses clauses. As @marcov already mentioned Point is a windows specific structure/record.
@Degibbo use it like this:
classes.Point or types.Point

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Polygon points
« Reply #6 on: August 01, 2017, 11:01:47 am »
The issue only occurs when windows is in the uses clauses. As @marcov already mentioned Point is a windows specific structure/record.
@Degibbo use it like this:
classes.Point or types.Point
Correct. Of course not the part about windows specific, because it isn't. TPoint(s) needs a clean up.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Degibbo

  • New member
  • *
  • Posts: 23
Re: Polygon points (Solved) + more
« Reply #7 on: August 02, 2017, 02:06:27 am »
G'day all,
Thanks for all the hints!  The trick was to include the unit "Types".
"Windows" was also included but not needed.  I got the points OK now.

Cheers & thanks for the support,
DG

« Last Edit: August 02, 2017, 04:20:57 am by Degibbo »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus