gpi А вот и исполнение моей идеи:
Код: модуль fs_isysrtti.pas
//begin fix
function MyRound(X:Extended; N: Integer): Extended;
var
i,i1: Integer;
begin
Result := X;
i1 := 1;
for i := 1 to N do
i1 := i1*10;
result := Trunc(Result*i1+0.5)/i1;
end;
//end fix
constructor TFunctions.Create;
begin
FCatStr := 'ctString';
FCatDate := 'ctDate';
FCatConv := 'ctConv';
FCatFormat := 'ctFormat';
FCatMath := 'ctMath';
FCatOther := 'ctOther';
//......
//begin fix
AddMethod('function RoundTo(X:Extended; N: Integer): Extended', CallMethod6, FCatMath);
//end fix
end;
function TFunctions.CallMethod6(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
begin
if MethodName = 'ROUND' then
Result := Integer(Round(Params[0]))
//begin fix
else if MethodName = 'ROUNDTO' then
Result := MyRound(Params[0], Params[1])
//end fix
else if MethodName = 'TRUNC' then
Result := Integer(Trunc(Params[0]))
else if MethodName = 'INT' then
Result := Int(Params[0])
else if MethodName = 'FRAC' then
Result := Frac(Params[0])
else if MethodName = 'SQRT' then
Result := Sqrt(Params[0])
else if MethodName = 'ABS' then
Result := Abs(Params[0])
else if MethodName = 'SIN' then
Result := Sin(Params[0])
else if MethodName = 'COS' then
Result := Cos(Params[0])
else if MethodName = 'ARCTAN' then
Result := ArcTan(Params[0])
else if MethodName = 'TAN' then
Result := Sin(Params[0]) / Cos(Params[0])
else if MethodName = 'EXP' then
Result := Exp(Params[0])
else if MethodName = 'LN' then
Result := Ln(Params[0])
else if MethodName = 'PI' then
Result := Pi
end;