ArgExprMethod
Returns the object instance of the expression that's passed as an argument to a
uCalc.Callback function+++Example
Parameters
Index
Int32
Index of the given argument. Note that
Index is 1-based; the
Index for the first arg is 1 (not 0)
Returns
Returns parsed expression object with which you can call functions like
Evaluate or
Execute
Example 1: Evaluate an expression only during callback
Sub EvaluateCallbackCB(ByVal ExprPartPtr As IntPtr)
Dim ExprPart As New uCalc.Callback(ExprPartPtr)
Console.WriteLine(ExprPart.ArgExpr(1).Evaluate())
Console.WriteLine(ExprPart.ArgExpr(2).EvaluateStr())
End Sub
Sub EvaluateCallback()
uc.DefineFunction("f(ByExpr Ex, ByExpr ExStr As String)", uc.PinAddr(AddressOf EvaluateCallbackCB))
uc.Eval("f(10+20*4, 'Hello' + ' There ' +UCase('Friends'))")
End Sub
static void EvaluateCallbackCB(IntPtr ExprPartPtr) {
var ExprPart = New uCalc.Callback(ExprPartPtr);
Console.WriteLine(ExprPart.ArgExpr(1).Evaluate());
Console.WriteLine(ExprPart.ArgExpr(2).EvaluateStr());
}
static void EvaluateCallback() {
uc.DefineFunction("f(ByExpr Ex, ByExpr ExStr As String)", uc.PinAddr(EvaluateCallbackCB));
uc.Eval("f(10+20*4, 'Hello' + ' There ' +UCase('Friends'))");
}
procedure EvaluateCallbackCB(ExprPartPtr: System.Pointer);
begin
WriteLn(ExprPart.ArgExpr(1).Evaluate());
WriteLn(ExprPart.ArgExpr(2).EvaluateStr());
End;
procedure EvaluateCallback();
begin
uc.DefineFunction('f(ByExpr Ex, ByExpr ExStr As String)', EvaluateCallbackCB);
uc.Eval('f(10+20*4, "Hello" + " There " +UCase("Friends"))');
End;
void _stdcall EvaluateCallbackCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
cout << ExprPart.ArgExpr(1).Evaluate() << endl;
cout << ExprPart.ArgExpr(2).EvaluateStr() << endl;
}
void EvaluateCallback() {
uc.DefineFunction("f(ByExpr Ex, ByExpr ExStr As String)", EvaluateCallbackCB);
uc.Eval("f(10+20*4, 'Hello' + ' There ' +UCase('Friends'))");
}
static void EvaluateCallbackCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
Console::WriteLine(ExprPart.ArgExpr(1).Evaluate());
Console::WriteLine(ExprPart.ArgExpr(2).EvaluateStr());
}
static void EvaluateCallback() {
uc.DefineFunction("f(ByExpr Ex, ByExpr ExStr As String)", ucPinAddr(EvaluateCallbackCB));
uc.Eval("f(10+20*4, 'Hello' + ' There ' +UCase('Friends'))");
}
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ArgExpr")> _
Private Function ArgExpr__(ByVal ExprPartHandle As IntPtr,ByVal Index As Int32) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ArgExpr")]
protected static extern IntPtr ArgExpr_(IntPtr ExprPartHandle, Int32 Index);
{DLLImport}function ArgExpr__(ExprPartHandle: System.Pointer;Index: Int32): System.Pointer; cdecl; external uCalcDLL name 'ArgExpr';
typedef uCalcPtr (* __ArgExpr)(void *ExprPartHandle, int32_t Index);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ArgExpr")]
static uCalcPtr ArgExpr_(void * ExprPartHandle, Int32 Index);