What functions are predefined in the JCL TEvaluator class

Does anyone know which predefined functions (e.g. ABS function) are included in the TEvaluator JCL class for Delphi 7?

+4
source share
3 answers

The standard Math.pas function includes no standard functions. All that is implemented in the default evaluation analyzer is the operators or , xor , and , not , mod , + , - , / , * , < > , <= , >= , = , div , cmp , bor , bxor , band , bnot , shl and shr , (How much I found in quick source checking, and a few I skipped based on @David's comment.)

You can easily add features (including those that are part of Delphi RTL) for the evaluator. This is even shown in a demo that adds functions from one of the JCL blocks.

The JCL evaluator example (ExprEvalExample.dpr), found by default in the JCL\examples\common\expreval folder JCL\examples\common\expreval , passes < ExprEvalExampleLogic.pas to the Init function in ExprEvalExampleLogic.pas as the FuncList parameter, which is filled with this code ( TEasyEvaluator functions in the same same routine) with functions from JclMath.pas :

  with FuncList do begin Add('LogBase10'); Add('LogBase2'); Add('LogBaseN'); Add('ArcCos'); Add('ArcCot'); Add('ArcCsc'); Add('ArcSec'); Add('ArcSin'); Add('ArcTan'); Add('ArcTan2'); Add('Cos'); Add('Cot'); Add('Coversine'); Add('Csc'); Add('Exsecans'); Add('Haversine'); Add('Sec'); Add('Sin'); Add('Tan'); Add('Versine'); Add('ArcCosH'); Add('ArcCotH'); Add('ArcCscH'); Add('ArcSecH'); Add('ArcSinH'); Add('ArcTanH'); Add('CosH'); Add('CotH'); Add('CscH'); Add('SecH'); Add('SinH'); Add('TanH'); end; 

These will be the features supported in the demo application. You can add your own in a similar way.

+4
source

No predefined functions are included. There are standard arithmetic operators: +, -, *, div and mod. And there are all the standard logical and bitwise operators. But nothing like abs, sin, exp, magazine, etc. You have to put them in yourself. It’s hard to add features, and I think this is a good design, allowing you to choose exactly what your evaluator supports.

+3
source

I use the above example provided by JCL, I cannot add any other function if I add the following: Evaluator.AddFunc ('power', power);

I get an error

[dcc32 error] ExprEvalExampleLogic.pas (56): E2250 There is no overloaded version of AddFunc that can be called with these arguments

-1
source

All Articles