Dew MtxVec NET
TExprFunc Type
Summary
Function type for custom function definition.

Unit
MtxParseClass

Declaration
TExprFunc = procedure(Expr: TExprRec);
Description
Any custome defined function must be of this type to be used in the expression parser.

Example 1

Custom function definition taking a single parameter stored at Args[0]. The second parameter (if present) would be stored at Args[1] and so on...
procedure _log10x(Param: TExprRec); begin with Param, Res do begin Complex := Args[0].Complex; if Complex then PCValue^ := Log10(Args[0].PCValue^) else PValue^ := Log10(Args[0].PValue^); end; end; var ep: TMtxExpression; begin ep := TMtxExpression.Create; try ep.DefineFunction('Log10x',_log10x,1); ep.Add('Log10x(1.2)+3'); Label1.Caption := SampleToStr(ep.Evaluate); finally ep.Destroy; end; end;

Copyright 2008 Dew Research
http://www.dewresearch.com