Int32 DefineFunction(String AFunctName, TExprFunc AFuncAddress, Int32 NArguments, Int32 NResults, String Help)
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
using Dew.Math;
using Dew.Math.Units;
namespace Dew.Examples
{
void Example()
{
void _Factorial_D (TExprRec Param)
{
Param.Res.DefineDouble;
Param.Res.DoubleValue = Fact(System.Math.Round(Param.Args[0].DoubleValue));
}
void Example(TMtxExpression MyParser)
{
myParser.DefineFunction("fact_double", _Factorial_D, 1, "fact_double(x): factorial function");
}
}
}
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