Sub ErrRaiseTestCB(ByVal ExprPartPtr As IntPtr)
Dim ExprPart As New uCalc.Callback(ExprPartPtr)
if ExprPart.Arg(1) = 123 Then ExprPart.ErrorRaise(ErrorNumberEnum.Err_Unrecognized_Command)
ExprPart.ReturnDbl(ExprPart.Arg(1))
End Sub
Sub ErrRaiseTest()
uc.DefineFunction("ErrRaiseTest(Value)", uc.PinAddr(AddressOf ErrRaiseTestCB))
Console.WriteLine(uc.EvalStr("ErrRaiseTest(111)")) ' Returns 111
Console.WriteLine(uc.EvalStr("ErrRaiseTest(123)")) ' Returns "Unrecognized command": ' Our callback arbitrarily raises an error for 123
End Sub
static void ErrRaiseTestCB(IntPtr ExprPartPtr) {
var ExprPart = New uCalc.Callback(ExprPartPtr);
if (ExprPart.Arg(1) == 123) ExprPart.ErrorRaise(ErrorNumberEnum.Err_Unrecognized_Command);
ExprPart.Return(ExprPart.Arg(1));
}
static void ErrRaiseTest() {
uc.DefineFunction("ErrRaiseTest(Value)", uc.PinAddr(ErrRaiseTestCB));
Console.WriteLine(uc.EvalStr("ErrRaiseTest(111)")); // Returns 111;
Console.WriteLine(uc.EvalStr("ErrRaiseTest(123)")); // Returns "Unrecognized command"; // Our callback arbitrarily raises an error for 123
}
procedure ErrRaiseTestCB(ExprPartPtr: System.Pointer);
begin
//var ExprPart: uCalc.CreateCallback(ExprPartPtr);
if ExprPart.Arg(1) = 123 Then ExprPart.ErrorRaise(ErrorNumberEnum.Err_Unrecognized_Command);
ExprPart.Return(ExprPart.Arg(1));
End;
procedure ErrRaiseTest();
begin
uc.DefineFunction('ErrRaiseTest(Value)', ErrRaiseTestCB);
WriteLn(uc.EvalStr('ErrRaiseTest(111)')); // Returns 111;
WriteLn(uc.EvalStr('ErrRaiseTest(123)')); // Returns 'Unrecognized command'; // Our callback arbitrarily raises an error for 123
End;
void _stdcall ErrRaiseTestCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
if (ExprPart.Arg(1) == 123) ExprPart.ErrorRaise(ErrorNumberEnum::Err_Unrecognized_Command);
ExprPart.Return(ExprPart.Arg(1));
}
void ErrRaiseTest() {
uc.DefineFunction("ErrRaiseTest(Value)", ErrRaiseTestCB);
cout << uc.EvalStr("ErrRaiseTest(111)") << endl; // Returns 111;
cout << uc.EvalStr("ErrRaiseTest(123)") << endl; // Returns "Unrecognized command"; // Our callback arbitrarily raises an error for 123
}
static void ErrRaiseTestCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
if (ExprPart.Arg(1) == 123) ExprPart.ErrorRaise(ErrorNumberEnum::Err_Unrecognized_Command);
ExprPart.Return(ExprPart.Arg(1));
}
static void ErrRaiseTest() {
uc.DefineFunction("ErrRaiseTest(Value)", ucPinAddr(ErrRaiseTestCB));
Console::WriteLine(uc.EvalStr("ErrRaiseTest(111)")); // Returns 111;
Console::WriteLine(uc.EvalStr("ErrRaiseTest(123)")); // Returns "Unrecognized command"; // Our callback arbitrarily raises an error for 123
}
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ErrorRaise")> _
Private Function ErrorRaise__(ByVal ExprPartHandle As IntPtr,ByVal ErrNumber As ErrorNumberEnum) As Int32
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ErrorRaise")]
protected static extern Int32 ErrorRaise_(IntPtr ExprPartHandle,ErrorNumberEnum ErrNumber);
{DLLImport}function ErrorRaise__(ExprPartHandle: System.Pointer;ErrNumber: ErrorNumberEnum): Int32; cdecl; external uCalcDLL name 'ErrorRaise';
typedef int32_t (* __ErrorRaise)(void *ExprPartHandle, ErrorNumberEnum ErrNumber);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ErrorRaise")]
static Int32 ErrorRaise_(void * ExprPartHandle, ErrorNumberEnum ErrNumber);