This is similar to Evaluate, but applies only to integer expressions.
Dim VariableX = uc.DefineVariable("x")
Dim Expression As string
Console.Write("Enter an expression (Ex: x / 2): ")
Expression = Console.ReadLine()
Dim ParsedExpr = uc.Parse(Expression, "Integer"): ' NOTE: Expression must be parsed as a 32-bit integer for EvaluateInt32 to work;
Dim x As double
for x = 1 To 10
VariableX.SetVariableValue(x)
Console.WriteLine("x = " + x + " Result = " + ParsedExpr.EvaluateInt32())
Next
' Output
' x = 1 Result = 0
' x = 2 Result = 1
' x = 3 Result = 1
' x = 4 Result = 2
' x = 5 Result = 2
' x = 6 Result = 3
' x = 7 Result = 3
' x = 8 Result = 4
' x = 9 Result = 4
' x = 10 Result = 5
var VariableX = uc.DefineVariable("x");
string Expression;
Console.Write("Enter an expression (Ex: x / 2): ");
Expression = Console.ReadLine();
var ParsedExpr = uc.Parse(Expression, "Integer"); // NOTE: Expression must be parsed as a 32-bit integer for EvaluateInt32 to work;
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
Console.WriteLine("x = " + x + " Result = " + ParsedExpr.EvaluateInt32());
}
// Output
// x = 1 Result = 0
// x = 2 Result = 1
// x = 3 Result = 1
// x = 4 Result = 2
// x = 5 Result = 2
// x = 6 Result = 3
// x = 7 Result = 3
// x = 8 Result = 4
// x = 9 Result = 4
// x = 10 Result = 5
ParsedExpr.Release();
VariableX.Release();
//var VariableX = uc.DefineVariable('x');
Write('Enter an expression (Ex: x / 2): ')
Expression = ReadLn();
//var ParsedExpr = uc.Parse(Expression, 'Integer'); // NOTE: Expression must be parsed as a 32-bit integer for EvaluateInt32 to work;
for x := 1 to 10 do
begin
VariableX.SetVariableValue(x);
WriteLn('x = ' + x + ' Result = ' + ParsedExpr.EvaluateInt32());
End;
// Output
// x = 1 Result = 0
// x = 2 Result = 1
// x = 3 Result = 1
// x = 4 Result = 2
// x = 5 Result = 2
// x = 6 Result = 3
// x = 7 Result = 3
// x = 8 Result = 4
// x = 9 Result = 4
// x = 10 Result = 5
auto VariableX = uc.DefineVariable("x");
string Expression;
cout << "Enter an expression (Ex: x / 2): " << endl;
cin >> Expression; // Ex: x / 2
auto ParsedExpr = uc.Parse(Expression, "Integer"); // NOTE: Expression must be parsed as a 32-bit integer for EvaluateInt32 to work;
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
cout << "x = " << x << " Result = " << ParsedExpr.EvaluateInt32() << endl;
}
// Output
// x = 1 Result = 0
// x = 2 Result = 1
// x = 3 Result = 1
// x = 4 Result = 2
// x = 5 Result = 2
// x = 6 Result = 3
// x = 7 Result = 3
// x = 8 Result = 4
// x = 9 Result = 4
// x = 10 Result = 5
ParsedExpr.Release();
VariableX.Release();
auto VariableX = uc.DefineVariable("x");
string ^ Expression;
Console::Write("Enter an expression (Ex: x / 2): ");
Expression = Console::ReadLine();
auto ParsedExpr = uc.Parse(Expression, "Integer"); // NOTE: Expression must be parsed as a 32-bit integer for EvaluateInt32 to work;
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
Console::WriteLine("x = " + x + " Result = " + ParsedExpr.EvaluateInt32());
}
// Output
// x = 1 Result = 0
// x = 2 Result = 1
// x = 3 Result = 1
// x = 4 Result = 2
// x = 5 Result = 2
// x = 6 Result = 3
// x = 7 Result = 3
// x = 8 Result = 4
// x = 9 Result = 4
// x = 10 Result = 5
ParsedExpr.Release();
VariableX.Release();
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="EvaluateInt32")> _
Private Function EvaluateInt32__(ByVal ExprHandle As IntPtr) As Int32
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="EvaluateInt32")]
protected static extern Int32 EvaluateInt32_(IntPtr ExprHandle);
{DLLImport}function EvaluateInt32__(ExprHandle: System.Pointer): Int32; cdecl; external uCalcDLL name 'EvaluateInt32';
typedef int32_t (* __EvaluateInt32)(void *ExprHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "EvaluateInt32")]
static Int32 EvaluateInt32_(void * ExprHandle);