unit tEx059Unit;
// Just to test the assignment operator :=
// It doesn't work as I would like.
// I would like the assignment operator := to be defined as any comparaison
// operator, but without returning any results. For example :
// operator := (var rOut:RRecTest; rIn:RRecTest);
// rOut.blabla:=rIn.blabla

// Thus I will use the  <=  operator as an assignment operator,
// ignoring the boolean result.

INTERFACE
//"""""""

uses wGlobals2;

// To test the assignment operator
type
  PRRecTest = ^RRecTest;
  RRecTest = record
    nAA,nBB,nCC : int32;
    end;

//operator := (var rSrc:RRecTest)rRes:RRecTest;
//===========================================
// This leads to "Error: Impossible to overload assignment for equal types"

// This can be defined, but it is unused by the compilator... -> Useless
operator := (var rOut:RRecTest; rIn:RRecTest) fRes:boolean;

operator <= (var rOut:RRecTest; rIn:RRecTest) fRes:boolean;
//=========================================================
// Ignoring the boolean result, this can be used as an assignment operator.
// It is not very satisfying using this trick, because the BIG DANGER is that
// the := operator is used. This will not generate a compiler error,
// but not give a working program.

operator + (rIn1,rIn2:RRecTest) rRes:RRecTest;
//============================================

IMPLEMENTATION
//""""""""""""

Uses wDebug0;

var nNotUsed : integer; // only to avoid an error message while compliling in DevPascal 1.9

// This can be defined, but it is unused by the compilator... -> Useless
operator := (var rOut:RRecTest; rIn:RRecTest) fRes:boolean;
//=========================================================
begin
// This  DBW  shows that this "procedure" is not used
DBW(1, 'in :=' + ITS5(rOut.nAA) + ITS5(rOut.nBB) + ITS5(rOut.nCC));
rOut.nAA:=rIn.nAA;
rOut.nBB:=rIn.nBB;
// rOut.nCC:=rIn.nCC; // This field stay as it is
fRes:=TRUE;
end;  // operator :=

operator <= (var rOut:RRecTest; rIn:RRecTest) fRes:boolean;
//=========================================================
begin
rOut.nAA:=rIn.nAA;
rOut.nBB:=rIn.nBB;
// rOut.nCC:=rIn.nCC; // This field stay as it is
fRes:=TRUE;
end;  // operator <=

operator + (rIn1,rIn2:RRecTest) rRes:RRecTest;
//============================================
begin
rRes.nAA:=rIn1.nAA + rIn2.nAA;
rRes.nBB:=rIn1.nBB + rIn2.nBB;
rRes.nCC:=rIn1.nCC + rIn2.nCC;
end;  // operator +

end. // unit tEx059Unit;
