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

ucDefine

Defines an item, such as a function, operator, variable, constant, syntax, pattern, etc...

ucDefineFunction

Defines a function

ucDefineOperator

Defines an operator

ucDefineSyntax

Defines a syntax

ucDefineVariable

Defines a variable

ucError

Returns the error number of the most recent transaction

ucErrorMessage

Returns an error message

ucEval

Evaluates an expression in one step, returning a numeric result

ucEvalStr

Evaluates an expression in one step, returning the result as a string

ucEvaluate

Rapidly evaluates an expression that was already parsed with ucParse

ucEvaluateStr

Same as ucEvaluate, but returns a string

ucNewThread

Allocates a new thread

ucParse

Parses an expression; returns a handle for use with ucEvaluate

ucReleaseItem

Releases an Item

ucSetError

Raises an error