This can be used in cases where the reutrn value is not needed, such as statements that represent code to be executed
rather than a math expression.
Dim VariableX = uc.DefineVariable("x")
Dim Total = uc.DefineVariable("Total")
Dim Expression As string
Console.Write("Enter an expression (Ex: Total = Total + x^2 + 5): ")
Expression = Console.ReadLine()
Dim ParsedExpr = uc.Parse(Expression)
Dim x As double
for x = 1 To 10
VariableX.SetVariableValue(x)
ParsedExpr.Execute()
Console.WriteLine(uc.Eval("x") + " Sub total = " + uc.Eval("Total"))
Next
' Output
' 1 Sub total = 6
' 2 Sub total = 15
' 3 Sub total = 29
' 4 Sub total = 50
' 5 Sub total = 80
' 6 Sub total = 121
' 7 Sub total = 175
' 8 Sub total = 244
' 9 Sub total = 330
' 10 Sub total = 435
var VariableX = uc.DefineVariable("x");
var Total = uc.DefineVariable("Total");
string Expression;
Console.Write("Enter an expression (Ex: Total = Total + x^2 + 5): ");
Expression = Console.ReadLine();
var ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
ParsedExpr.Execute();
Console.WriteLine(uc.Eval("x") + " Sub total = " + uc.Eval("Total"));
}
// Output
// 1 Sub total = 6
// 2 Sub total = 15
// 3 Sub total = 29
// 4 Sub total = 50
// 5 Sub total = 80
// 6 Sub total = 121
// 7 Sub total = 175
// 8 Sub total = 244
// 9 Sub total = 330
// 10 Sub total = 435
Console.WriteLine("Total = " + uc.Eval("Total")); // Returns "Total = 435";
ParsedExpr.Release();
VariableX.Release();
//var VariableX = uc.DefineVariable('x');
//var Total = uc.DefineVariable('Total');
Write('Enter an expression (Ex: Total = Total + x^2 + 5): ')
Expression = ReadLn();
//var ParsedExpr = uc.Parse(Expression);
for x := 1 to 10 do
begin
VariableX.SetVariableValue(x);
ParsedExpr.Execute();
WriteLn(uc.Eval('x') + ' Sub total = ' + uc.Eval('Total'));
End;
// Output
// 1 Sub total = 6
// 2 Sub total = 15
// 3 Sub total = 29
// 4 Sub total = 50
// 5 Sub total = 80
// 6 Sub total = 121
// 7 Sub total = 175
// 8 Sub total = 244
// 9 Sub total = 330
// 10 Sub total = 435
auto VariableX = uc.DefineVariable("x");
auto Total = uc.DefineVariable("Total");
string Expression;
cout << "Enter an expression (Ex: Total = Total + x^2 + 5): " << endl;
cin >> Expression; // Ex: Total = Total + x^2 + 5
auto ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
ParsedExpr.Execute();
cout << uc.Eval("x") << " Sub total = " << uc.Eval("Total") << endl;
}
// Output
// 1 Sub total = 6
// 2 Sub total = 15
// 3 Sub total = 29
// 4 Sub total = 50
// 5 Sub total = 80
// 6 Sub total = 121
// 7 Sub total = 175
// 8 Sub total = 244
// 9 Sub total = 330
// 10 Sub total = 435
cout << "Total = " << uc.Eval("Total") << endl; // Returns "Total = 435";
ParsedExpr.Release();
VariableX.Release();
auto VariableX = uc.DefineVariable("x");
auto Total = uc.DefineVariable("Total");
string ^ Expression;
Console::Write("Enter an expression (Ex: Total = Total + x^2 + 5): ");
Expression = Console::ReadLine();
auto ParsedExpr = uc.Parse(Expression);
for (double x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
ParsedExpr.Execute();
Console::WriteLine(uc.Eval("x") + " Sub total = " + uc.Eval("Total"));
}
// Output
// 1 Sub total = 6
// 2 Sub total = 15
// 3 Sub total = 29
// 4 Sub total = 50
// 5 Sub total = 80
// 6 Sub total = 121
// 7 Sub total = 175
// 8 Sub total = 244
// 9 Sub total = 330
// 10 Sub total = 435
Console::WriteLine("Total = " + uc.Eval("Total")); // Returns "Total = 435";
ParsedExpr.Release();
VariableX.Release();
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="Execute")> _
Private Sub Execute__(ByVal ExprHandle As IntPtr)
End Sub
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="Execute")]
protected static extern void Execute_(IntPtr ExprHandle);
{DLLImport}procedure Execute__(ExprHandle: System.Pointer); cdecl; external uCalcDLL name 'Execute';
typedef void (* __Execute)(void *ExprHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "Execute")]
static void Execute_(void * ExprHandle);