function DefineFunction(const AFunctName: string; AFuncAddress: TExprFunc; NArguments: Integer; NResults: Integer; const Help: string): Integer;
Defines new function.
| # | Name | Description |
|---|---|---|
| 1 | AFunctName | Defines 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. |
| 2 | AFuncAddress | |
| 3 | NArguments | Defines number of arguments for function. |
| 4 | NResults | Defines number of arguments, which are treated as results. NResults <= NArguments |
| 5 | Help | Function 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