I know you don't like objects, but maybe something like :

====================================================

unit uAxisRecord;

{$mode objfpc}{$H+}

interface

uses
 Classes, SysUtils;

type

 { TAxisRecord }

 TAxisRecord
 =
  object
    X,Y,Z,A,B,C: Double;
    function Value_from_Letter( _Axisletter:Char): double;
    procedure ShowAxis( _Axisletter:Char);
  end;

implementation

{ TAxisRecord }

function TAxisRecord.Value_from_Letter(_Axisletter: Char): double;
begin
     case _Axisletter
     of
       'X': Result:= X;
       'Y': Result:= Y;
       'Z': Result:= Z;
       'A': Result:= A;
       'B': Result:= B;
       'C': Result:= C;
       else Result:= X;//or throw an exception
       end;
end;

procedure TAxisRecord.ShowAxis(_Axisletter: Char);
begin
     WriteLn( Value_from_Letter( _Axisletter));
end;

end.

==========================================

And then where you need it:

...
uses uAxisRecord
...

Var
  AxisValue : TAxisRecord;

...

Procedure ShowAxis(Axisletter:Char);
Begin
   Writeln(AxisValue.Value_from_Letter( Axisletter);
End;

or just:

AxisValue.ShowAxis('X');

"object" works as "record", no need to allocate or call a constructor, but you can define methods on it.

(I didn't test but it should work)

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

Reply via email to