Can anyone provide a working example for how to use the TRAP_EXCEPTION@ intrinsic function? The example included in the help file is not functional. If I type in the help file code 'as-is' I get an error that TRAP_EXCEPTION@ was declared as external twice, once in the included exceptn.ins file and once in the example code. If I comment out the declaration in the example code, then nothing happens when I execute. Watching execution in the debugger it looks like the value of FLT_DIV_ZERO isn't available in the example code. Thanks in advance for advice on getting this function to work.
Usage of TRAP_EXCEPTION@
Yes. The declaration of TRAP_EXCEPTION@ is in EXCEPTN.INS so it should removed from the code...
PROGRAM TrapException
INCLUDE <EXCEPTN.INS>
INTEGER DivZeroHandler, OldHandler
EXTERNAL DivZeroHandler
REAL r, zero
OldHandler=TRAP_EXCEPTION@(FLT_DIV_ZERO, DivZeroHandler)
zero=0.0
r=1.234/zero
PRINT *, 'Normal termination'
END
INTEGER FUNCTION DivZeroHandler()
INCLUDE <EXCEPTN.INS>
PRINT *, 'Float divide by zero trapped'
DivZeroHandler= NONCONTINUABLE_EXCEPTION
END
This program now functions correctly on the assumption that continuation after a divide by zero is not possible. The exception is handled and reported but continuation is not possible in this case.
Which exception are you interested in? If I remember correctly, some exceptions can be trapped with full recovery.