- 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.
- TSthEvaluator: An arithmetic evaluation class. Capable of variables.
- 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.
These are examples for valid formulas:
7+b; 8*ans (same as above)
0.3–0.3.2 — 2007-05-25
- Fixed a nasty bug with brackets
- Fixed a bug with handling unary functions when they’re written without brackets. log 100 + log 100 was interpreted as log(100 + log(100))
- Implemented OnNumber
- Allow backslashes in numbers to enable the user to accept numbers like \b001 (you need to interpret \b yourself)
AllowVariablesWithCapitalsimplemented (needed, as normally, loweracse letters are for variables and upper case letters for numbers in other number systems like hex)
AllowEmptyAssignmentsas cosmetic property. This way a=; b=; are valid. I needed this at work.
ldas synonym for
log2to the function list