Rx Parser

RX Library

Control Name Unit Class
RX ANI File. Parsing TRxMathParser

Description:
The TRxMathParser is a class for parsing and evaluating simple mathematical expressions specified at run-time. The programming interface is simple: specify expression to be evaluated in AFormula parameter of Exec method, call Exec and retrieve computed value as result of Exec method.

When calculating error occured the ERxParserError exception is raised.

Accepted operators:
+ , - , * , /

The following functions are supported; it doesn't matter if you use lower or upper case:
Arctan, Cos, Sin, Tan, Abs, Exp, Ln, Log, Sqrt, Sqr, Int, Fraq.


Method Exec
Declaration: function Exec(AFormula: String): Double;

Call Exec to retrieve computed value of expression specified by AFormula parameter. When calculating error occured the ERxParserError exception is raised.

Method Exec example

if rxMathParser1.Exec('2+Cos(2)') then
Label1.Caption := 'Ok! Result = ' + FloatToStr(rxMathParser1.ResValue);


Routine GetFormulaValue
Declaration: function GetFormulaValue(const Formula: string): Double;

Call GetFormulaValue to retrieve computed value of expression specified by Formula parameter. This function uses TRxMathParser class to calculate an expression.

GetFormulaValue example:

Value := GetFormulaValue('2 * Sqrt(4)');
{ here Value is 4 }


Index Page | About | Download
Creation Date: 4 Feb 1998 | Last Update: 16 Mar 2000