Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tpoint explanation?

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
US
Ok, i'm trying to understand the tpoint array.

If i write tpoint[0].X:=1;
tpoint[0].Y:=2;

Everything is fine...
Now if I declare temp:integer;
and write temp:=tpoint[0].x;

It compiles fine but crashes when the program runs.
How do i get the value in tpoint[0].x?

Thanks.
Po
 
pierrotsc,

please post more code!
Be aware that TPoint is a record and NOT an array.

here is how to it;
Code:
type TPoints = array of TFPoint;

var MyTPoints : TPoints; //declare dynamic array

procedure test;
begin
 SetLength(MyTPoints, 2); // make room for 2 TPoint records, Index starts from 0
 MyTPoints[0].X := 10;
 MyTPoints[0].Y := 10;
 MyTPoints[1].X := 100;
 MyTPoints[1].Y := 100;
 ShowMessage(IntToStr(MyTPoints[0].X ));
 ShowMessage(IntToStr(MyTPoints[1].X ));
end;

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks, that's what i meant with tpoint. the showmessage (intostr(mytpoints[0].x) just display the value. How to get put back this value into avariable?
if i try:
var temp:integer;
temp:=mytpoints[0].x;
it will compile fine but will crash when the program hits this line of code.

Thanks.
 
again, show all the code...

if the showmessage works, then the
temp:=MyTPoints[0].X must work also

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I found my mistake. I was resetting the array to a size 0. That's why it was crashing. Sorry for the post.
PO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top