TMtxExpression.DefineFunction Method

function DefineFunction(const AFunctName: string; AFuncAddress: TExprFunc; NArguments: Integer; NResults: Integer; const Help: string): Integer;

Defines new function.

#NameDescription
1AFunctNameDefines function name. If a function with the same name was already definded, it is redefined and all expressions which contain the symbol AFuncName will be recompiled before the next evaluation.
2AFuncAddress
3NArgumentsDefines number of arguments for function.
4NResultsDefines number of arguments, which are treated as results. NResults <= NArguments
5HelpFunction help text.

Returns: Int32

Examples
procedure _Factorial_D (Param: TExprRec)
begin
    Param.Res.DefineDouble;
    Param.Res.DoubleValue:= Fact(Round(Param.Args[0].DoubleValue));
end;

procedure Example(MyParser: TMtxExpression);
begin
    myParser.DefineFunction('fact_double', _Factorial_D, 1, 'fact_double(x): factorial function');
end;
See Also: TMtxExpression.Undefine, TMtxExpression.VarByName, TMtxExpression.GetVarList, TMtxExpression.DefineVariable, TMtxExpression.DefineDouble, TMtxExpression.DefineComplex, TMtxExpression.DefineMatrix, TMtxExpression.DefineVector, TMtxExpression.DefineVaryingFunction, TMtxExpression.DefineOperator, TMtxExpression.DefineDoubleConstant, TMtxExpression.DefineComplexConstant