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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,df5a27b6159d7882 X-Google-Attributes: gid103376,public From: labtek@cs.yale.edu (Tom Griest) Subject: Re: Strange problem in GNAT 3.04 Win 95 Date: 1996/10/26 Message-ID: <54to1mINNqeb@RA.DEPT.CS.YALE.EDU>#1/1 X-Deja-AN: 192301688 distribution: world references: <32707cd0.8077937@news.demon.co.uk> organization: Yale University Computer Science Dept., New Haven, CT 06520-2158 newsgroups: comp.lang.ada Date: 1996-10-26T00:00:00+00:00 List-Id: smoore@chowgar.demon.co.uk (Simon Moore) writes: >If anybody has got the time could they please take a look at the >listing below. The code seems syntactically and semantically correct >but doesn't perform as it should. You are missing statement to flush the rest of the input line when you do a get on the integer. You need a Skip_Line; after the Get(Choice); [snip] > PUT_LINE("1 - Get a natural"); > PUT_LINE("2 - Get a character"); > PUT_LINE("3 - Nothing"); > PUT_LINE("4 - Nothing"); > NEW_LINE; > PUT_LINE("0 - Exit"); > > GET(choice); > > -- ** GET(c); -- THIS IS THE IMPORTANT LINE > Get(C) will not work in the general case, and specifically if the user enters additional (possibly space) characters after the number. BTW, it is good practice to use bullet-proof input routines for this sort of thing, since a user making a typo could easily get an unhandled exception in your example. The reason why case 1 works, but not case two is that the get on integer is defined to scan over non-numeric characters, whereas get on a character simply returns the next input character. -Tom