Hi again.
I've written a small unit to work with 3D vectors. It compiles without errors, but when I'm trying to use the operators I defined from a program I get the "invalid operands to binary" error. But I can use the type defined in the unit without problems. The source code is the following: *************************** Unit vectores;
Interface
{$X+} {$W-} Type TVector = Record x, y, z: Real; End;
Operator + ( a, b: TVector ) c : TVector;
Operator - ( a, b : TVector ) c : TVector;
Operator * ( a, b : TVector ) c : Real;
Operator / ( a : TVector; b : Real ) c : TVector;
Operator * ( a : TVector; b : Real) c : TVector;
Operator * ( a : Real; b : TVector) c : TVector;
Function modu ( a : TVector ) : real;
Implementation
Operator + ( a, b: TVector ) c : TVector; Begin c.x := a.x + b.x; c.y := a.y + b.y; c.z := a.z + b.z; End;
Operator - ( a, b : TVector ) c : TVector; Begin c.x := a.x - b.x; c.y := a.y - b.y; c.z := a.z - b.z; End;
Operator * ( a, b : TVector ) c : Real; Begin c := (a.x * b.x) + (a.y * b.y) + (a.z * b.z); End;
Operator / ( a : TVector; b : Real ) c : TVector; Begin c.x:=a.x / b; c.y:=a.y / b; c.z:=a.z / b; End;
Operator * ( a : TVector; b : Real) c : TVector; Begin c.x:=a.x*b; c.y:=a.y*b; c.z:=a.z*b; End;
Operator * ( a : Real; b : TVector) c : TVector; Begin c.x:=a*b.x; c.y:=a*b.y; c.z:=a*b.z; End;
Function modu ( a : TVector ) : real; Begin modu := sqrt(sqr(a.x)+sqr(a.y)+sqr(a.z)); End;
{$W+}
End. ***************************
Does anybody know what's wrong?
Thank you, Ariel
--- Ariel Bendersky bender@einstein.com.ar
According to Bendersky:
I've written a small unit to work with 3D vectors. It compiles without errors, but when I'm trying to use the operators I defined from a program I get the "invalid operands to binary" error.
Which version of GPC are you using? Mine (gpc-980410) does what it should with your unit (at least for my tiny test program). If you have something older than April 1998, I recommend to upgrade. See:
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/alpha/
Greetings
Peter
Thanks, I'm downloading the latest alpha right now.
Thanks again, Ariel.
From: Peter Gerwinski peter@gerwinski.de Subject: Re: Units To: bender@einstein.com.ar (Bendersky) Date: Wed, 15 Apr 1998 03:06:15 +0200 (MEST) Cc: gpc@hut.fi
According to Bendersky:
I've written a small unit to work with 3D vectors. It compiles without errors, but when I'm trying to use the operators I defined from a program I get the "invalid operands to binary" error.
Which version of GPC are you using? Mine (gpc-980410) does what it should with your unit (at least for my tiny test program). If you have something older than April 1998, I recommend to upgrade. See:
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/alpha/
Greetings
Peter
-- Peter Gerwinski, Essen, Germany, free physicist and programmer Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - 10 Apr 1998 PGP key fingerprint: AC 6C 94 45 BE 28 A4 96 0E CC E9 12 47 25 82 75 Fight the SPAM! - http://maps.vix.com/
--- Ariel Bendersky bender@einstein.com.ar