OpItemMethod
Returns the function or operator
Item of the current expression part
Example 1: Determining properties of an expression part
Sub OpItemTestCB(ByVal ExprPartPtr As IntPtr)
Dim ExprPart As New uCalc.Callback(ExprPartPtr)
Console.WriteLine("Name: " + ExprPart.OpItem().Name())
Console.WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name())
Console.WriteLine("Param count: " + ExprPart.OpItem().ElementCount())
Console.WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator_))
End Sub
Sub HandleTest()
uc.DefineFunction("AAA() As Double", uc.PinAddr(AddressOf OpItemTestCB))
uc.DefineFunction("BBB(x, y, z) As String", uc.PinAddr(AddressOf OpItemTestCB))
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum.GroupLeftToRight, uc.PinAddr(AddressOf OpItemTestCB)):
uc.EvalStr("AAA()")
uc.EvalStr("BBB(9, 8, 7)")
uc.EvalStr("5 CCC 4")
End Sub
static void OpItemTestCB(IntPtr ExprPartPtr) {
var ExprPart = New uCalc.Callback(ExprPartPtr);
Console.WriteLine("Name: " + ExprPart.OpItem().Name());
Console.WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name());
Console.WriteLine("Param count: " + ExprPart.OpItem().ElementCount());
Console.WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator));
}
static void HandleTest() {
uc.DefineFunction("AAA() As Double", uc.PinAddr(OpItemTestCB));
uc.DefineFunction("BBB(x, y, z) As String", uc.PinAddr(OpItemTestCB));
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum.GroupLeftToRight, uc.PinAddr(OpItemTestCB));
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
procedure OpItemTestCB(ExprPartPtr: System.Pointer);
begin
WriteLn('Name: ' + ExprPart.OpItem().Name());
WriteLn('Data type: ' + ExprPart.OpItem().GetDataType().Name());
WriteLn('Param count: ' + ExprPart.OpItem().ElementCount());
WriteLn('Is operator? ' + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator_));
End;
procedure HandleTest();
begin
uc.DefineFunction('AAA() As Double', OpItemTestCB);
uc.DefineFunction('BBB(x, y, z) As String', OpItemTestCB);
uc.DefineOperator('{x} CCC {y} As Int32', 0, GroupingEnum.GroupLeftToRight, OpItemTestCB);
uc.EvalStr('AAA()');
uc.EvalStr('BBB(9, 8, 7)');
uc.EvalStr('5 CCC 4');
End;
void _stdcall OpItemTestCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
cout << "Name: " << ExprPart.OpItem().Name() << endl;
cout << "Data type: " << ExprPart.OpItem().GetDataType().Name() << endl;
cout << "Param count: " << ExprPart.OpItem().ElementCount() << endl;
cout << "Is operator? " << ExprPart.OpItem().IsProperty(ItemIsEnum::Operator) << endl;
}
void HandleTest() {
uc.DefineFunction("AAA() As Double", OpItemTestCB);
uc.DefineFunction("BBB(x, y, z) As String", OpItemTestCB);
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum::GroupLeftToRight, OpItemTestCB);
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
static void OpItemTestCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
Console::WriteLine("Name: " + ExprPart.OpItem().Name());
Console::WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name());
Console::WriteLine("Param count: " + ExprPart.OpItem().ElementCount());
Console::WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum::Operator));
}
static void HandleTest() {
uc.DefineFunction("AAA() As Double", ucPinAddr(OpItemTestCB));
uc.DefineFunction("BBB(x, y, z) As String", ucPinAddr(OpItemTestCB));
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum::GroupLeftToRight, ucPinAddr(OpItemTestCB));
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="OpItem")> _
Private Function OpItem__(ByVal ExprPartHandle As IntPtr) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="OpItem")]
protected static extern IntPtr OpItem_(IntPtr ExprPartHandle);
{DLLImport}function OpItem__(ExprPartHandle: System.Pointer): System.Pointer; cdecl; external uCalcDLL name 'OpItem';
typedef uCalcPtr (* __OpItem)(void *ExprPartHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "OpItem")]
static uCalcPtr OpItem_(void * ExprPartHandle);