created: 2005-11-27
modified: 2007-05-25

Stefan.Huberdoc.at

TSthEvaluator: An expression evaluator

Version Information
Version: 0.3.2, updated: 2007-05-25
Developed with Delphi5, arithmetic evaluator
uSthEvaluator-0.3.2.zip (8KB, zipped source code).
0.3.2 fixes serious bugs with evaluating functions. Anyone should definitely upgrade.
Content
TSthEvaluator: An arithmetic evaluation class. Capable of variables.
Licence
uSthEvaluator.pas comes under the MIT licence. Have a look at the source file for further details. I am looking forward to feedback via eMail.

TSthEvaluator is an arithmetic evaluation class for Object Pascal (developed with Delphi 5). A given expression string is taken as input and numerically evaluated. You can use variables in the expression. Unknown variables will trigger an event where you may react and set the variable properly. Some constants are there as well and can easily be extended. Variable assignment and multiple evaluations per formula are possible.

Operator precedence is respected and parentheses are supported.

Some arithmetic functions such as sin, cos, abs, ceil, floor, round and some more are supported. It is easy to extend the evaluator to process other unary functions or binary operators.

Unary functions are functions that take one parameter, like sin(), cos(), sqrt(). Binary operators are what we normally use in everyday life. One operator with two arguments, like +, -, *, /, mod, div.

Examples

These are examples for valid formulas:
2*(2+a)
a=7+b; 8*a
7+b; 8*ans (same as above)
a=5; b=a*6
deg(2*pi)

Changelog

0.3–0.3.2 — 2007-05-25

Contact & ImprintKontakt & Impressum
Created: 2005-11-27 — last modified: 2007-05-25 — last update of web site: 2012-01-25
Follow me: RSS Follow StefanMHuber on Twitter