EvaluateMethod
Rapidly evaluates a floating point expression that was parsed with
Parse or passed By Expression
Example 1: Displaying a different result for each value of x based on the expression parsed with Parse
Dim VariableX = uc.DefineVariable("x")
Dim Expression As string
Console.Write("Enter an expression (Ex: x^2 * 10): ")
Expression = Console.ReadLine()
Dim ParsedExpr = uc.Parse(Expression)
Dim x As double
for x = 1 To 10
VariableX.SetVariableValue(x)
Console.WriteLine("x = " + x + " Result = " + ParsedExpr.Evaluate())
Next
ParsedExpr.Release()
VariableX.Release()
var VariableX = uc.DefineVariable("x");
string Expression;
Console.Write("Enter an expression (Ex: x^2 * 10): ");
Expression = Console.ReadLine();
var ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
Console.WriteLine("x = " + x + " Result = " + ParsedExpr.Evaluate());
}
ParsedExpr.Release();
VariableX.Release();
Write('Enter an expression (Ex: x^2 * 10): ')
Expression = ReadLn();
for x := 1 to 10 do
begin
VariableX.SetVariableValue(x);
WriteLn('x = ' + x + ' Result = ' + ParsedExpr.Evaluate());
End;
ParsedExpr.Release();
VariableX.Release();
auto VariableX = uc.DefineVariable("x");
string Expression;
cout << "Enter an expression (Ex: x^2 * 10): " << endl;
cin >> Expression;
auto ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
cout << "x = " << x << " Result = " << ParsedExpr.Evaluate() << endl;
}
ParsedExpr.Release();
VariableX.Release();
auto VariableX = uc.DefineVariable("x");
string ^ Expression;
Console::Write("Enter an expression (Ex: x^2 * 10): ");
Expression = Console::ReadLine();
auto ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
Console::WriteLine("x = " + x + " Result = " + ParsedExpr.Evaluate());
}
ParsedExpr.Release();
VariableX.Release();
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="Evaluate")> _
Private Function Evaluate__(ByVal ExprHandle As IntPtr) As Double
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="Evaluate")]
protected static extern double Evaluate_(IntPtr ExprHandle);
{DLLImport}function Evaluate__(ExprHandle: System.Pointer): Double; cdecl; external uCalcDLL name 'Evaluate';
typedef double (* __Evaluate)(void *ExprHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "Evaluate")]
static double Evaluate_(void * ExprHandle);