unit tEx060Unit;
// Just to test the assignment operator :=  under DOS
// 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
//"""""""

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

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

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

// This is how the assignment operator should be defined,  I think
//operator := (var rOut:RRecTest; rIn:RRecTest);

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 program working the wanted way.

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

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

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  writeln  shows that this "procedure" is not used
writeln('in :=', rOut.nAA:5, rOut.nBB:5, rOut.nCC:5);
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:=0;  // This field is changed, to see that the <= operator works but not the :=
end;  // operator +

end. // unit tEx060Unit;
