<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I know you don't like objects, but maybe something like :</p>
<p>====================================================<br>
</p>
<pre>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.
</pre>
<p>==========================================</p>
<p>And then where you need it:</p>
<pre>...
uses uAxisRecord
...</pre>
<pre class="moz-quote-pre" wrap=""><pre>Var
AxisValue : TAxisRecord;</pre><pre>...</pre><pre>
Procedure ShowAxis(Axisletter:Char);
Begin
Writeln(AxisValue.Value_from_Letter( Axisletter);
End;
</pre></pre>
<p>or just:<br>
</p>
<pre class="moz-quote-pre" wrap="">AxisValue.ShowAxis('X');
</pre>
<p>"object" works as "record", no need to allocate or call a
constructor, but you can define methods on it.<br>
</p>
<p>(I didn't test but it should work)</p>
</body>
</html>