Thanks for this suggestion, it looks promising.
You're welcome and it is a nice way to 'solve' your issue.
However, I can't make sense of what the documentation is saying there, so it's going to take me several days to experiment and figure out how the syntax/semantics work.
I have to get out the door in a jiffy so no time but when back I'll try to come up with some code for you (unless someone else beats me to it) or perhaps you want to give it try yourself first.
edit: back
example:
program test;
{$mode objfpc}{$H+}
uses
sysutils;
type
TRecordType1 = record
x: integer;
y: single;
z: boolean;
end;
TRecordType2 = record
x: string;
y: string;
z: string;
end;
operator := (source: TRecordType1) destination: TRecordType2;
begin
destination.x := source.x.ToString;
destination.y := source.y.ToString;
destination.z := source.z.ToString;
end;
operator := (source: TRecordType2) destination: TRecordType1;
begin
destination.x := source.x.ToInteger;
destination.y := source.y.ToSingle;
destination.z := source.z.ToBoolean;
end;
var
R1: TRecordType1;
R2: TRecordType2;
begin
R1 := default(TRecordType1);
R2 := default(TRecordType2);
writeln('R1.x := ', R1.x);
writeln('R1.y := ', R1.y);
writeln('R1.z := ', R1.z);
writeln;
writeln('R2.x := ', R2.x);
writeln('R2.y := ', R2.y);
writeln('R2.z := ', R2.z);
writeln;
R1.x := 12;
R1.y := 34.56;
R1.z := true;
R2 := R1;
writeln('R2.x := ', R2.x);
writeln('R2.y := ', R2.y);
writeln('R2.z := ', R2.z);
writeln;
R2.x := '100';
R2.y := '768.394';
R2.z := 'false';
R1 := R2;
writeln('R1.x := ', R1.x);
writeln('R1.y := ', R1.y);
writeln('R1.z := ', R1.z);
end.
which outputs:
R1.x := 0
R1.y := 0.000000000E+00
R1.z := FALSE
R2.x :=
R2.y :=
R2.z :=
R2.x := 12
R2.y := 34.56000137
R2.z := -1
R1.x := 100
R1.y := 7.683939819E+02
R1.z := FALSE
The destination name in the operator header declaration is perhaps a bit weird but can be omitted (in which case you should address the return value with the result modifier the same as you would for a function result).
Is that example more clear or do you perhaps still have questions ?