 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Nathan Hatcher
Joined: 09 Apr 2010 Posts: 1
|
Posted: Fri May 24, 2013 4:51 pm Post subject: Usage of TRAP_EXCEPTION@ |
|
|
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. _________________ Nate Hatcher
Optimized Gas Treating, Inc. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Fri May 24, 2013 7:23 pm Post subject: |
|
|
Yes. The declaration of TRAP_EXCEPTION@ is in EXCEPTN.INS so it should removed from the code...
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. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|