On 12/20/2020 7:11 AM, Luca Olivetti via fpc-pascal wrote:

Then change your data model.

Instead of

Axis_record = record
  X,Y,Z,A,B,C    : Double;
End;

use

AxisName = (X,Y,Z,A,B,C);
Axis_record = array[AxisName] of double;

then it's easy to do what you want.

procedure DoSomething(var Axis:Axis_record; const which:AxisName);
begin
  Axis[which]:=Axis[which]/2;
end;

Bye

+1

I think this is a typical example where properly thinking about a solution for a programming issue BEFORE going with what seems as the logical choice at first glance leads to a much simpler solution without coming up with all kinds of fancy workarounds...

Ralf



--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to