From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,76a7f1309448592f X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: HELP:intercepting program exit!! Date: 1996/05/20 Message-ID: <4npuhi$oca@newsbf02.news.aol.com>#1/1 X-Deja-AN: 155746136 sender: root@newsbf02.news.aol.com references: <4nha2f$qda@soleil.uvsq.fr> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-05-20T00:00:00+00:00 List-Id: Tuyet-Tram DANG-NGOC 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