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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e89e4fc8b5c5f198 X-Google-Attributes: gid103376,public From: smize@news.imagin.net (Samuel Mize) Subject: Re: get_line Date: 1998/06/05 Message-ID: <6l9jts$30dh$1@prime.imagin.net>#1/1 X-Deja-AN: 359937457 References: Reply-To: smize@imagin.net (Samuel Mize) Organization: ImagiNet Communications Ltd, Arlington, Texas Newsgroups: comp.lang.ada Date: 1998-06-05T00:00:00+00:00 List-Id: In article , Steve Dyrdahl wrote: >The problem (on our Unix system anyway) is that if the user types more >characters than the string will hold. The "leftover" characters are still >left in the input buffer and will be read on the next execution of the >loop. This isn't Unix, it's Ada. >I am wondering if there is a clean solution for flushing the input buffer Get_Line stops reading if you ran out of space in your string buffer. So, you need to check for that, and call Skip_Line: Get_Line (S, Last); if Last = S'Last then Skip_Line; end if; You could put this into a procedure, that will then behave as you expected Get_Line to do. If you want to avoid a possible exception on end of file, use: if Last = S'Last and then not End_Of_File then Here's another useful wheel for you, if you have web access: Deja News, http://www.dejanews.com . I did a "power search" (lets you search a specific newsgroup) in comp.lang.ada with "+get_line +end +line" and got 53 matching postings, of which at least five answered your question. (After that I quit reading them.) I don't point this out to be pissy about frequently asked questions -- OK, well, not JUST to be pissy. I use Deja News all the time for this kind of question, and it's not only useful for reducing the bandwidth, it's a MUCH faster way to get your answer. (The plus sign means "must include this word", otherwise you get, e.g., posts that include "get_line" and "end" but not "line"). No affiliation with Deja News, YMMV, no warranty express or implied. Best, Sam Mize -- Samuel Mize -- smize@imagin.net (home email) -- Team Ada Multi-part MIME message: " ", " ", " " (hands waving) Fight Spam - see http://www.cauce.org/