Silverfrost Logo About Us | Contact Us
 

SET_TRAP@

Platform

Win32

Purpose

Install a user defined exception handler for Ctrl+C (Win32 only).

Syntax

INTEGER(KIND=3) SET_TRAP@(ROUTINE, EXCEPTION)
INTEGER(KIND=3) EXCEPTION, ROUTINE
EXTERNAL ROUTINE

Description

EXCEPTION is set to zero to handle CTRL+C. The function ROUTINE is installed as the handler for this event. The location of the previous handler is returned. If the application is to terminate then ROUTINE should return a zero value. Otherwise a value of 1 is returned.

Example

PROGRAM TrapException
  INTEGER SET_TRAP@, OldHandler
  EXTERNAL SET_TRAP@, CtrlcHandler
  OldHandler=SET_TRAP@(CtrlcHandler, 0)
  DO WHILE(.TRUE.)
   PRINT *, 'Continuing. . .'
  ENDWHILE
  PRINT *, 'Normal termination'
END
INTEGER FUNCTION CtrlcHandler()
  STOP 'Ctrl+C trapped'
  CtrlcHandler=0
END

 

 

Copyright © 1999-2017 Silverfrost Limited