TMtxExpression.DefineFunction Method

Int32 DefineFunction(String AFunctName, TExprFunc AFuncAddress, Int32 NArguments, Int32 NResults, String Help)

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
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