uCalc
FMP Overview
uCalc FMP is a 32-bit DLL component for Windows 98/Me/XP/Vista, which allows your program to evaluate expressions that are defined at runtime. The first example that follows shows the simplest way to evaluate an expression. You simply call ucEval() with the math expression you want to evaluate, and you immediately get a result. The second example parses an expression in a first step with ucParse, and then rapidly evaluates it millions of times in a loop with ucEvaluate.
Example 1: Simple evaluation
UserExpression$ = InputBox("Enter an
expression",, "6+4*5/2")
Print ucEval(UserExpression$) ' This returns 16
Example 2: Fast evaluation millions of times in a loop
Dim ExprPtr As Long, xPtr As Long
Dim x As Double, SumTotal As Double
Dim TimerStart As Single, TimerEnd As Single
UserExpression$ = InputBox("Enter an
expression",, "x^2+5*x+4")
xPtr = ucDefineVariable("x
As Double", VarPtr(x))
ExprPtr = ucParse(UserExpression$)
TimerStart = Timer
For x = 1 To 5000000
SumTotal =
SumTotal + ucEvaluate(ExprPtr)
Next
TimerEnd = Timer - TimerStart
Print "The total is: "; SumTotal
Print "Elapsed Time: " + Format$(TimerEnd,
"0.00") + " second(s)"
ucReleaseItem
ExprPtr
ucReleaseItem
xPtr
The details on how to get started will depend on which compiler you are using. Click on one of the following supported compilers for more details:
C++ Builder, Delphi, PowerBASIC, Visual Basic (classic), Visual Basic .NET, Visual C++ .
Here is a summary of uCalc FMP routines:
|
uCalc (advanced) |
Encapsulates all of uCalc FMP's (and Language Builder's) functionality |
|
Defines an item, such as a function, operator, variable, constant, syntax, pattern, etc... |
|
|
Defines a function |
|
|
Defines an operator |
|
|
Defines a syntax |
|
|
Defines a variable |
|
|
Returns the error number of the most recent transaction |
|
|
Returns an error message |
|
|
Evaluates an expression in one step, returning a numeric result |
|
|
Evaluates an expression in one step, returning the result as a string |
|
|
Rapidly evaluates an expression that was already parsed with ucParse |
|
|
Same as ucEvaluate, but returns a string |
|
|
Allocates a new thread |
|
|
Parses an expression; returns a handle for use with ucEvaluate |
|
|
Releases an Item |
|
|
Raises an error |