ErrorSymbolMethod
Returns the symbol associated with the error that is raised
Example 1: Adding error handlers
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_()
uc.AddErrorHandler(uc.PinAddr(AddressOf ErrorHandlerTestCB))
uc.AddErrorHandler(uc.PinAddr(AddressOf AutoVariableDefCB))
Console.WriteLine(uc.EvalStr("1+"))
Console.WriteLine(uc.EvalStr("5/0"))
uc.Eval("AutoTest = 123")
Console.WriteLine(uc.Eval("AutoTest * 1000"))
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_() {
uc.AddErrorHandler(uc.PinAddr(ErrorHandlerTestCB));
uc.AddErrorHandler(uc.PinAddr(AutoVariableDefCB));
Console.WriteLine(uc.EvalStr("1+"));
Console.WriteLine(uc.EvalStr("5/0"));
uc.Eval("AutoTest = 123");
Console.WriteLine(uc.Eval("AutoTest * 1000"));
}
procedure ErrorHandlerTestCB(ucPtr: System.Pointer);
begin
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
if ucc.ErrorNumber() = ErrorNumberEnum.Err_Undefined_Identifier Then
begin
ucc.DefineVariable(ucc.ErrorSymbol());
ucc.ErrorResponse(ErrorHandlerResponseEnum.ErrorResume);
End;
End;
procedure ErrorHandler_();
begin
uc.AddErrorHandler(ErrorHandlerTestCB);
uc.AddErrorHandler(AutoVariableDefCB);
WriteLn(uc.EvalStr('1+'));
WriteLn(uc.EvalStr('5/0'));
uc.Eval('AutoTest = 123');
WriteLn(uc.Eval('AutoTest * 1000'));
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_() {
uc.AddErrorHandler(ErrorHandlerTestCB);
uc.AddErrorHandler(AutoVariableDefCB);
cout << uc.EvalStr("1+") << endl;
cout << uc.EvalStr("5/0") << endl;
uc.Eval("AutoTest = 123");
cout << uc.Eval("AutoTest * 1000") << endl;
}
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_() {
uc.AddErrorHandler(ucPinAddr(ErrorHandlerTestCB));
uc.AddErrorHandler(ucPinAddr(AutoVariableDefCB));
Console::WriteLine(uc.EvalStr("1+"));
Console::WriteLine(uc.EvalStr("5/0"));
uc.Eval("AutoTest = 123");
Console::WriteLine(uc.Eval("AutoTest * 1000"));
}
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ErrorSymbol")> _
Private Function ErrorSymbol__(ByVal uCalcHandle As IntPtr) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ErrorSymbol")]
protected static extern IntPtr ErrorSymbol_(IntPtr uCalcHandle);
{DLLImport}function ErrorSymbol__(uCalcHandle: System.Pointer): PAnsiChar; cdecl; external uCalcDLL name 'ErrorSymbol';
typedef const char * (* __ErrorSymbol)(void *uCalcHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ErrorSymbol")]
static STR_RETURN ErrorSymbol_(void * uCalcHandle);