replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Usage of TRAP_EXCEPTION@
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Usage of TRAP_EXCEPTION@

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Nathan Hatcher



Joined: 09 Apr 2010
Posts: 1

PostPosted: Fri May 24, 2013 4:51 pm    Post subject: Usage of TRAP_EXCEPTION@ Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Fri May 24, 2013 7:23 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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