FPEnvRaiseExceptionMethod

Applies to:uCalc Transform
Class:uCalc
Raises a floating point exception in a uCalc.Callback function
Syntax
FPEnvRaiseException(Exception)
Remarks
This attempts to raise the exception(s) specfied by the Exception parameter. This is based on the C++ feraiseexcept() function. If you are using C++, you may use the pre-defined macro values of FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW, FE_UNDERFLOW, FE_ALL_EXCEPT. If you are using another compiler, you may use the matching members of the FPEnvExceptionEnum enumerator.

Example 1: Raising a floating point exception

Sub FPEnvRaiseTestCB(ByVal ExprPartPtr As IntPtr)
   Dim ExprPart As New uCalc.Callback(ExprPartPtr)
   ExprPart.GetuCalc().FPEnvRaiseException(FPEnvExceptionEnum.Invalid)
End Sub

Sub FPEnvRaiseTest()
   uc.DefineFunction("FPEnvRaiseTest()", uc.PinAddr(AddressOf FPEnvRaiseTestCB))
   ' Note: If the exception is masked then EvalStr returns an error message
   '       otherwise the exception must be cought with a Try block.
   Console.WriteLine(uc.EvalStr("FPEnvRaiseTest()")) ' Returns "Invalid operation"
End Sub

          

static void FPEnvRaiseTestCB(IntPtr ExprPartPtr) {
   var ExprPart = New uCalc.Callback(ExprPartPtr);
   ExprPart.GetuCalc().FPEnvRaiseException(FPEnvExceptionEnum.Invalid);
}

static void FPEnvRaiseTest() {
   uc.DefineFunction("FPEnvRaiseTest()", uc.PinAddr(FPEnvRaiseTestCB));
   // Note: If the exception is masked then EvalStr returns an error message
   //       otherwise the exception must be cought with a Try block.
   Console.WriteLine(uc.EvalStr("FPEnvRaiseTest()")); // Returns "Invalid operation";
}

          

procedure FPEnvRaiseTestCB(ExprPartPtr: System.Pointer);
begin
   
//var ExprPart: uCalc.CreateCallback(ExprPartPtr);
   ExprPart.GetuCalc().FPEnvRaiseException(FPEnvExceptionEnum.Invalid);
End;

procedure FPEnvRaiseTest();
begin
   
   uc.DefineFunction('FPEnvRaiseTest()', FPEnvRaiseTestCB);
   // Note: If the exception is masked then EvalStr returns an error message
   //       otherwise the exception must be cought with a Try block.
   WriteLn(uc.EvalStr('FPEnvRaiseTest()')); // Returns 'Invalid operation';
End;

          

void _stdcall FPEnvRaiseTestCB(uCalcPtr ExprPartPtr) {
   auto ExprPart = uCalc::Callback(ExprPartPtr);
   ExprPart.GetuCalc().FPEnvRaiseException(FPEnvExceptionEnum::Invalid);
}

void FPEnvRaiseTest() {
   uc.DefineFunction("FPEnvRaiseTest()", FPEnvRaiseTestCB);
   // Note: If the exception is masked then EvalStr returns an error message
   //       otherwise the exception must be cought with a Try block.
   cout << uc.EvalStr("FPEnvRaiseTest()") << endl; // Returns "Invalid operation";
}

          

static void FPEnvRaiseTestCB(uCalcPtr ExprPartPtr) {
   auto ExprPart = uCalc::Callback(ExprPartPtr);
   ExprPart.GetuCalc().FPEnvRaiseException(FPEnvExceptionEnum::Invalid);
}

static void FPEnvRaiseTest() {
   uc.DefineFunction("FPEnvRaiseTest()", ucPinAddr(FPEnvRaiseTestCB));
   // Note: If the exception is masked then EvalStr returns an error message
   //       otherwise the exception must be cought with a Try block.
   Console::WriteLine(uc.EvalStr("FPEnvRaiseTest()")); // Returns "Invalid operation";
}

          
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="FPEnvRaiseException")> _

Private Function FPEnvRaiseException__(ByVal uCalcHandle As IntPtr, ByVal Exception As FPEnvExceptionEnum  ) As  Int32
End Function
            
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="FPEnvRaiseException")]

protected static extern  Int32 FPEnvRaiseException_(IntPtr uCalcHandle, FPEnvExceptionEnum Exception  );
            
{DLLImport}function FPEnvRaiseException__(uCalcHandle: System.Pointer; Exception: FPEnvExceptionEnum):  Int32; cdecl; external uCalcDLL name 'FPEnvRaiseException';

            
typedef  int32_t (* __FPEnvRaiseException)(void *uCalcHandle,  FPEnvExceptionEnum Exception  ); 

            
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "FPEnvRaiseException")]

static Int32 FPEnvRaiseException_(void *  uCalcHandle,  FPEnvExceptionEnum Exception);
            
Prev | Next