- 4.45.2.26. -
Table of Contents
4. Standard Units
4.45. Math - Extended Mathematics unit
4.45.2. Math Unit Procedures and Functions
4.45.2.26. Evaluate procedure
4.45.2.26. Evaluate procedure
Targets: MS-DOS, OS/2, Win32
Math Unit
Evaluates the given expression.
Declaration:
procedure Evaluate(Expr: String;
var Result: Extended;
var ErrCode: Longint);
Remarks:
Use Evaluate to evaluate any valid expression given in
Expr. The Result variable returns the evaluated
expression. If it succeeds, the ErrCode variable is 0.
Examples:
uses
Math, Strings;
const
Expr = 'cos(0)*(5^2-3.1)';
var
Result: Extended;
ErrCode: Longint;
begin
Evaluate(Expr, Result, ErrCode);
if ErrCode = 0 then
Writeln(Expr, ' = ', Fls(Result))
else
Writeln('Invalid expression');
end.
The example above will print 21.9.
- 4.45.2.26. -