You are here: Symbol Reference > MtxParseExpr Namespace > Classes > TMtxExpression Class > public > DefineFunction Method > TMtxExpression.DefineFunction Method (string, TExprFunc, Integer, Integer, string)
MtxVec VCL
ContentsIndex
PreviousUpNext
TMtxExpression.DefineFunction Method (string, TExprFunc, Integer, Integer, string)

Defines new function.

Pascal
function DefineFunction(const AFunctName: string; AFuncAddress: TExprFunc; NArguments: Integer; NResults: Integer; const Help: string): integer; overload;
Parameters 
Description 
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. 
AFuncAddress 
 
NArguments 
Defines number of arguments for function. 
NResults 
Defines number of arguments, which are treated as results. NResults <= NArguments 
Help 
Function help text. 

Add factorial function to the function list.

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;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!