JCL Help:TEvaluator
From Project JEDI Wiki
Jump to navigationJump to searchJCL Help: TEvaluator Class
[+] JclExprEval.pas Classes
[+] TEvaluator Methods
Search in JCL Help
Search in all projectsClass Hierarchy
TEasyEvaluator
|
TEvaluator
Summary
Quick evaluator shell object.
Pascal
public TEvaluator = class(TEasyEvaluator);
Description
This is an encapsulation of a simple lexer and an evaluating parser. It evaluates while parsing, and it doesn't store any compiled expression. This means it evaluates quite quickly, but isn't very fast for repeated evaluations of the same expression.
Examples
Create a new project, remove the default form and replace the contents of the project file with this: uses SysUtils, JclExprEval, Dialogs;
function MyAdder(X, Y: Double): Double;
beginResult := X + Y + 0.12;
end;
var
evaluator: TEvaluator;
X: Double;
Y: Extended;
begin
evaluator := TEvaluator.Create;
try
evaluator.AddVar('X', X);
evaluator.AddVar('Y', Y);
evaluator.AddFunc('MyAdder', MyAdder);
X := 3.5;
Y := 0.7;
ShowMessage(Format('Delphi says: %.4g',
[MyAdder(X, Y)]));
ShowMessage(Format('TEvaluator says: %.4g',
[evaluator.Evaluate('MyAdder(X, Y)')]));
finally
evaluator.Free;
end;
end.
About
Unit
Donator
Barry Kelly
Contribute to this help topic
This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page