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,deeb88b0e7eede4f X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: Help with Exceptions! Date: 1996/05/07 Message-ID: <4mnj0f$kka@newsbf02.news.aol.com>#1/1 X-Deja-AN: 153493544 sender: root@newsbf02.news.aol.com references: <4mmimq$s4r@hatathli.csulb.edu> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-05-07T00:00:00+00:00 List-Id: rgelb@csulb.edu (Robert Gelb) asks: > ...when I catch an error with [an exception > handler], how can I go back to statement > where the error occured (or the statement > next to it)? In Ada an exception handler is executed *instead of* the rest of the procedure, function, block, etc. that raised the exception. There's no counterpart of Basic's RESUME or RESUME NEXT, and even a goto from an exception handler back to the unit that raised the exception is forbidden! Therefore, place your exception handler in a small block, so that only a small amount of code is skipped when the exception is raised, and place the entire block in a loop that runs until the code executes correctly. For example, this program fragment will keep getting input until the user types a valid integer; then it will go on: Valid : Boolean := False; Input : String(1 .. 80); Input_Len : Integer; Answer : Integer; ... while not Valid loop Put("Type an integer: "); Get_Line(Input, Input_Len); begin Answer := Integer'Value(Input(1 .. Input_Len)); Valid := True; exception when others => Put_Line("Invalid. Please try again."); end; end loop; Things are a bit more complicated for exceptions raised in a *declarative* region, but most exceptions are raised in an executable region. There's a more detailed explanation of exceptions and exception handlers in the Ada Tutor program, available for download at the Web and ftp sites below my signature. I hope this helps. - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor If a vegetarian is a person who eats vegetables, what does a humanitarian eat?