32-bit Calc32.dll provides CalcString function which takes a string with mathematical
expression, evaluates it and returns resulting value. CalcString can be called
from OPAL (Paradox 9, 10 or 11) or from ANY other language which supports calls
to 32-bit DLL. CalcString supports complex expressions with parenthesis structure
and various mathematical functions. It handles syntax and math errors. Paradox
users: see example Paradox form Calc32.fsl.
CalcString is written on Delphi and declared in the
Calc32.dll as:
function CalcString(stExpression:pchar;var result:Double):smallint;stdcall;export;
stExpression - expression to calculate (no more than 240 chars)
result - expression result
function returns:
0 - no errors
1 - syntax error in expression
2 - division by zero, overflow or other math error
3 - too long expression (>240 chars)
OPAL syntax:
CalcString(var stExpression string, var result number) smallint
Allowable OPERANDS (in the order of precedence)in
expressions:
+ - addition and substraction
* / multiplication and division
^ raising to a power, for example 5^2 - five in the second power
functions (see below)
() parenthesis - change order of precedence
Allowable FUNCTIONS (function names are case-insensitive):
LG common logarithm
LN natural logarithm
EXP exponential
SQRT square root
INT integer part of the argument
ABS absolute value
SGN sign:
= -1 if the argument is negative
= 0 if the argument is equal to zero
= +1 if the argument is positive
RAD transformation from degrees to radians
DEG transformation from radians to degrees
RND random number in the range [0,argument]
SIN sine
COS cosine
TAN tangent
ATAN arctangent
SH hyperbolic sine
CH hyperbolic cosine
TH hyperbolic tangent
ATH area-hyperbolic tangent
All trigonometric functions assume that their argument is in radians.
Allowable CONSTANTS:
PI 3.141592653590
NUMBERS can be either standard (120.1) or scientific
(example - 1.201E2) notations