comp.lang.ada
 help / color / mirror / Atom feed
* HELP:intercepting program exit!!
@ 1996-05-17  0:00 Tuyet-Tram DANG-NGOC
  1996-05-20  0:00 ` John Herro
  0 siblings, 1 reply; 2+ messages in thread
From: Tuyet-Tram DANG-NGOC @ 1996-05-17  0:00 UTC (permalink / raw)



Hi, 

Could someone tell me how to get the exception concerning a programm 
interruption(^C). 

Please, it's urgent!!!

Thanks.
-- 
Tuyet Tram DANG NGOC
Licence d'informatique
Universite de Versailles
dangngoc@ens-info.uvsq.fr
http://www.ens-info.uvsq.fr:8000/public/dangngoc/index.html





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: HELP:intercepting program exit!!
  1996-05-17  0:00 HELP:intercepting program exit!! Tuyet-Tram DANG-NGOC
@ 1996-05-20  0:00 ` John Herro
  0 siblings, 0 replies; 2+ messages in thread
From: John Herro @ 1996-05-20  0:00 UTC (permalink / raw)



Tuyet-Tram DANG-NGOC <dangngoc@ens-info.uvsq.fr> wrote:
> Could someone tell me how to get the
> exception concerning a programm 
> interruption(^C).  Please, it's urgent!!!
     You posted this three days ago, and, so far as I know, nobody replied
in comp.lang.ada.  I think that perhaps we don't understand your question
very well.  Since it's urgent, I'll try to answer.
     Do you want to raise an exception which you can handle when the user
strikes Ctrl-C?  To do this, you need to turn off the system's handling of
Crtl-C when you input a character from the keyboard.  How you do this
depends on your implementation of Ada.  For example, if you're using the
Open Ada compiler for DOS, you can do the following:

with TTY;
...
C     : Character;
Break : exception;
...
C := TTY.Get(Direct => True);
if C = Character'Val(3) then
   raise Break;
end if;

     Under DOS, this code will raise the user-defined exception Break if
the user types Ctrl-C or Ctrl-Break.  If you're using a different version
of Ada, but you're still using DOS, perhaps your Ada compiler will let you
call the DOS interrupts.  In that case, you want to look at interrupt
16#21#, functions 16#06# and 16#07#.
     If you use this code, you can't use Text_IO.Get_Line, or the program
will abort instead of raising Break when the user types Ctrl-C.  If you
need to get an entire line of text, you'll have to write your own version
of Get_Line that calls TTY.Get(Direct => True) repeatedly.
     I hope this helps.  If not, please tell us in more detail what you
want to do.  Tell us what system your program must run on, and tell us
what Ada compiler you're using.  Also, tell us if your compiler is Ada83
or Ada95, and one of us who knows your compiler will try to help you.
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-05-20  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-17  0:00 HELP:intercepting program exit!! Tuyet-Tram DANG-NGOC
1996-05-20  0:00 ` John Herro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox