EvaluateStrMethod
Rapidly evaluates an expression of any data type that was parsed with
Parse or passed By Expression returning a string
Example 1: displaying each character of a string on a separate line
Dim MyString As string
Console.Write("Enter an expression (Ex: 'This is a Test'): ")
MyString = Console.ReadLine()
Dim VariableX = uc.DefineVariable("x As Int32")
Dim MyStringVar = uc.DefineVariable("MyStringVar As String = " + MyString)
Dim ParsedExpr = uc.Parse("Substr(MyStringVar, x, 1)")
Dim StrLength = uc.Eval("Length(MyStringVar)")
Dim x As Int32
for x = 0 To StrLength-1
VariableX.SetVariableValueInt32(x)
Console.WriteLine(ParsedExpr.EvaluateStr())
Next
string MyString;
Console.Write("Enter an expression (Ex: 'This is a Test'): ");
MyString = Console.ReadLine();
var VariableX = uc.DefineVariable("x As Int32");
var MyStringVar = uc.DefineVariable("MyStringVar As String = " + MyString);
var ParsedExpr = uc.Parse("Substr(MyStringVar, x, 1)");
var StrLength = uc.Eval("Length(MyStringVar)");
for (Int32 x = 0; x <= StrLength-1; x++) {
VariableX.SetVariableValueInt32(x);
Console.WriteLine(ParsedExpr.EvaluateStr());
}
Write('Enter an expression (Ex: "This is a Test"): ')
MyString = ReadLn();
for x := 0 to StrLength-1 do
begin
VariableX.SetVariableValueInt32(x);
WriteLn(ParsedExpr.EvaluateStr());
End;
string MyString;
cout << "Enter an expression (Ex: 'This is a Test'): " << endl;
cin >> MyString;
auto VariableX = uc.DefineVariable("x As Int32");
auto MyStringVar = uc.DefineVariable("MyStringVar As String = " + MyString);
auto ParsedExpr = uc.Parse("Substr(MyStringVar, x, 1)");
auto StrLength = uc.Eval("Length(MyStringVar)");
for (int x = 0; x <= StrLength-1; x++) {
VariableX.SetVariableValueInt32(x);
cout << ParsedExpr.EvaluateStr() << endl;
}
string ^ MyString;
Console::Write("Enter an expression (Ex: 'This is a Test'): ");
MyString = Console::ReadLine();
auto VariableX = uc.DefineVariable("x As Int32");
auto MyStringVar = uc.DefineVariable("MyStringVar As String = " + MyString);
auto ParsedExpr = uc.Parse("Substr(MyStringVar, x, 1)");
auto StrLength = uc.Eval("Length(MyStringVar)");
for (int x = 0; x <= StrLength-1; x++) {
VariableX.SetVariableValueInt32(x);
Console::WriteLine(ParsedExpr.EvaluateStr());
}
Example 2: Displaying a different complex number result for each value of x based on the expression parsed with Parse
Dim x As double
Dim VariableX = uc.DefineVariable("x")
Dim Expression As string
Console.Write("Enter an expression (Ex: x * #i + 5): ")
Expression = Console.ReadLine()
Dim ParsedExpr = uc.Parse(Expression, "Complex"):
for x = 1 To 10
VariableX.SetVariableValue(x)
Console.WriteLine("x = " + x + " Result = " + ParsedExpr.EvaluateStr())
Next
ParsedExpr.Release()
VariableX.Release()
double x;
var VariableX = uc.DefineVariable("x");
string Expression;
Console.Write("Enter an expression (Ex: x * #i + 5): ");
Expression = Console.ReadLine();
var ParsedExpr = uc.Parse(Expression, "Complex");
for (x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
Console.WriteLine("x = " + x + " Result = " + ParsedExpr.EvaluateStr());
}
ParsedExpr.Release();
VariableX.Release();
Write('Enter an expression (Ex: x * #i + 5): ')
Expression = ReadLn();
for x := 1 to 10 do
begin
VariableX.SetVariableValue(x);
WriteLn('x = ' + x + ' Result = ' + ParsedExpr.EvaluateStr());
End;
ParsedExpr.Release();
VariableX.Release();
double x;
auto VariableX = uc.DefineVariable("x");
string Expression;
cout << "Enter an expression (Ex: x * #i + 5): " << endl;
cin >> Expression;
auto ParsedExpr = uc.Parse(Expression, "Complex");
for (x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
cout << "x = " << x << " Result = " << ParsedExpr.EvaluateStr() << endl;
}
ParsedExpr.Release();
VariableX.Release();
double x;
auto VariableX = uc.DefineVariable("x");
string ^ Expression;
Console::Write("Enter an expression (Ex: x * #i + 5): ");
Expression = Console::ReadLine();
auto ParsedExpr = uc.Parse(Expression, "Complex");
for (x = 1; x <= 10; x = x + 1) {
VariableX.SetVariableValue(x);
Console::WriteLine("x = " + x + " Result = " + ParsedExpr.EvaluateStr());
}
ParsedExpr.Release();
VariableX.Release();
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="EvaluateStr")> _
Private Function EvaluateStr__(ByVal ExprHandle As IntPtr) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="EvaluateStr")]
protected static extern IntPtr EvaluateStr_(IntPtr ExprHandle);
{DLLImport}function EvaluateStr__(ExprHandle: System.Pointer): PAnsiChar; cdecl; external uCalcDLL name 'EvaluateStr';
typedef const char * (* __EvaluateStr)(void *ExprHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "EvaluateStr")]
static STR_RETURN EvaluateStr_(void * ExprHandle);