Returns the error number of the most recently raised error.
Note: Errors are cleared whenever a new expression is parsed or a new item is defined.
Sub ErrorHandlerTestCB(ByVal ucPtr As IntPtr)
Dim ucc As New uCalc(ucPtr)
Console.WriteLine("An error has occured!")
Console.Write("Error #: "): Console.WriteLine(ucc.ErrorNumber())
Console.WriteLine("Error Message: " + ucc.ErrorMessage())
Console.WriteLine("Error Symbol: " + ucc.ErrorSymbol())
Console.WriteLine("Error Location: " + ucc.ErrorLocation())
Console.WriteLine("Error Expression: " + ucc.ErrorExpression())
End Sub
Sub AutoVariableDefCB(ByVal ucPtr As IntPtr)
Dim ucc As New uCalc(ucPtr)
if ucc.ErrorNumber() = ErrorNumberEnum.Err_Undefined_Identifier Then
ucc.DefineVariable(ucc.ErrorSymbol())
ucc.ErrorResponse(ErrorHandlerResponseEnum.ErrorResume)
End if
End Sub
Sub ErrorHandler_()' +++ example also for 2nd arg
uc.AddErrorHandler(uc.PinAddr(AddressOf ErrorHandlerTestCB))
uc.AddErrorHandler(uc.PinAddr(AddressOf AutoVariableDefCB))
Console.WriteLine(uc.EvalStr("1+")) ' Returns "Syntax error"
' Output
' An error has occured!
' Error #: 2
' Error Message: Syntax error
' Error Symbol: +
' Error Location: 1
' Error Expression: 1+
Console.WriteLine(uc.EvalStr("5/0")) ' Returns "Division by 0"
' Output
' An error has occured!
' Error #: 20
' Error Message: Division by 0
' Error Symbol:
' Error Location: 0
' Error Expression:
uc.Eval("AutoTest = 123")
Console.WriteLine(uc.Eval("AutoTest * 1000")) ' Returns 123000
End Sub
static void ErrorHandlerTestCB(IntPtr ucPtr) {
uCalc ucc = New uCalc(ucPtr);
Console.WriteLine("An error has occured!");
Console.Write("Error #: "); Console.WriteLine(ucc.ErrorNumber());
Console.WriteLine("Error Message: " + ucc.ErrorMessage());
Console.WriteLine("Error Symbol: " + ucc.ErrorSymbol());
Console.WriteLine("Error Location: " + ucc.ErrorLocation());
Console.WriteLine("Error Expression: " + ucc.ErrorExpression());
}
static void AutoVariableDefCB(IntPtr ucPtr) {
uCalc ucc = New uCalc(ucPtr);
if (ucc.ErrorNumber() == ErrorNumberEnum.Err_Undefined_Identifier) {
ucc.DefineVariable(ucc.ErrorSymbol());
ucc.ErrorResponse(ErrorHandlerResponseEnum.ErrorResume);
}
}
static void ErrorHandler_() { // +++ example also for 2nd arg
uc.AddErrorHandler(uc.PinAddr(ErrorHandlerTestCB));
uc.AddErrorHandler(uc.PinAddr(AutoVariableDefCB));
Console.WriteLine(uc.EvalStr("1+")); // Returns "Syntax error";
// Output
// An error has occured!
// Error #: 2
// Error Message: Syntax error
// Error Symbol: +
// Error Location: 1
// Error Expression: 1+
Console.WriteLine(uc.EvalStr("5/0")); // Returns "Division by 0";
// Output
// An error has occured!
// Error #: 20
// Error Message: Division by 0
// Error Symbol:
// Error Location: 0
// Error Expression:
uc.Eval("AutoTest = 123");
Console.WriteLine(uc.Eval("AutoTest * 1000")); // Returns 123000;
}
procedure ErrorHandlerTestCB(ucPtr: System.Pointer);
begin
//ucc uCalc.Create(ucPtr);;
WriteLn('An error has occured!');
Write('Error #: ');; WriteLn(ucc.ErrorNumber());
WriteLn('Error Message: ' + ucc.ErrorMessage());
WriteLn('Error Symbol: ' + ucc.ErrorSymbol());
WriteLn('Error Location: ' + ucc.ErrorLocation());
WriteLn('Error Expression: ' + ucc.ErrorExpression());
End;
procedure AutoVariableDefCB(ucPtr: System.Pointer);
begin
//ucc uCalc.Create(ucPtr);;
if ucc.ErrorNumber() = ErrorNumberEnum.Err_Undefined_Identifier Then
begin
ucc.DefineVariable(ucc.ErrorSymbol());
ucc.ErrorResponse(ErrorHandlerResponseEnum.ErrorResume);
End;
End;
procedure ErrorHandler_();
begin
// +++ example also for 2nd arg
uc.AddErrorHandler(ErrorHandlerTestCB);
uc.AddErrorHandler(AutoVariableDefCB);
WriteLn(uc.EvalStr('1+')); // Returns 'Syntax error';
// Output
// An error has occured!
// Error #: 2
// Error Message: Syntax error
// Error Symbol: +
// Error Location: 1
// Error Expression: 1+
WriteLn(uc.EvalStr('5/0')); // Returns 'Division by 0';
// Output
// An error has occured!
// Error #: 20
// Error Message: Division by 0
// Error Symbol:
// Error Location: 0
// Error Expression:
uc.Eval('AutoTest = 123');
WriteLn(uc.Eval('AutoTest * 1000')); // Returns 123000;
End;
void _stdcall ErrorHandlerTestCB(uCalcPtr ucPtr) {
uCalc ucc(ucPtr);
cout << "An error has occured!" << endl;
cout << "Error #: "; cout << ucc.ErrorNumber() << endl;
cout << "Error Message: " << ucc.ErrorMessage() << endl;
cout << "Error Symbol: " << ucc.ErrorSymbol() << endl;
cout << "Error Location: " << ucc.ErrorLocation() << endl;
cout << "Error Expression: " << ucc.ErrorExpression() << endl;
}
void _stdcall AutoVariableDefCB(uCalcPtr ucPtr) {
uCalc ucc(ucPtr);
if (ucc.ErrorNumber() == ErrorNumberEnum::Err_Undefined_Identifier) {
ucc.DefineVariable(ucc.ErrorSymbol());
ucc.ErrorResponse(ErrorHandlerResponseEnum::ErrorResume);
}
}
void ErrorHandler_() { // +++ example also for 2nd arg
uc.AddErrorHandler(ErrorHandlerTestCB);
uc.AddErrorHandler(AutoVariableDefCB);
cout << uc.EvalStr("1+") << endl; // Returns "Syntax error";
// Output
// An error has occured!
// Error #: 2
// Error Message: Syntax error
// Error Symbol: +
// Error Location: 1
// Error Expression: 1+
cout << uc.EvalStr("5/0") << endl; // Returns "Division by 0";
// Output
// An error has occured!
// Error #: 20
// Error Message: Division by 0
// Error Symbol:
// Error Location: 0
// Error Expression:
uc.Eval("AutoTest = 123");
cout << uc.Eval("AutoTest * 1000") << endl; // Returns 123000;
}
static void ErrorHandlerTestCB(uCalcPtr ucPtr) {
uCalc ucc(ucPtr);
Console::WriteLine("An error has occured!");
Console::Write("Error #: "); Console::WriteLine(ucc.ErrorNumber());
Console::WriteLine("Error Message: " + ucc.ErrorMessage());
Console::WriteLine("Error Symbol: " + ucc.ErrorSymbol());
Console::WriteLine("Error Location: " + ucc.ErrorLocation());
Console::WriteLine("Error Expression: " + ucc.ErrorExpression());
}
static void AutoVariableDefCB(uCalcPtr ucPtr) {
uCalc ucc(ucPtr);
if (ucc.ErrorNumber() == ErrorNumberEnum::Err_Undefined_Identifier) {
ucc.DefineVariable(ucc.ErrorSymbol());
ucc.ErrorResponse(ErrorHandlerResponseEnum::ErrorResume);
}
}
static void ErrorHandler_() { // +++ example also for 2nd arg
uc.AddErrorHandler(ucPinAddr(ErrorHandlerTestCB));
uc.AddErrorHandler(ucPinAddr(AutoVariableDefCB));
Console::WriteLine(uc.EvalStr("1+")); // Returns "Syntax error";
// Output
// An error has occured!
// Error #: 2
// Error Message: Syntax error
// Error Symbol: +
// Error Location: 1
// Error Expression: 1+
Console::WriteLine(uc.EvalStr("5/0")); // Returns "Division by 0";
// Output
// An error has occured!
// Error #: 20
// Error Message: Division by 0
// Error Symbol:
// Error Location: 0
// Error Expression:
uc.Eval("AutoTest = 123");
Console::WriteLine(uc.Eval("AutoTest * 1000")); // Returns 123000;
}
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ErrorNumber")> _
Private Function ErrorNumber__(ByVal uCalcHandle As IntPtr) As ErrorNumberEnum
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ErrorNumber")]
protected static extern ErrorNumberEnum ErrorNumber_(IntPtr uCalcHandle);
{DLLImport}function ErrorNumber__(uCalcHandle: System.Pointer): ErrorNumberEnum; cdecl; external uCalcDLL name 'ErrorNumber';
typedef ErrorNumberEnum (* __ErrorNumber)(void *uCalcHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ErrorNumber")]
static ErrorNumberEnum ErrorNumber_(void * uCalcHandle);