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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a1458d1793850de4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-16 18:01:58 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.he.net!newsfeed1.easynews.com!easynews.com!easynews!elnk-pas-nf1!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Interger_io get and Text_io.Get_line References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <9cHjb.3520$s93.924@newsread3.news.pas.earthlink.net> Date: Fri, 17 Oct 2003 01:01:57 GMT NNTP-Posting-Host: 63.184.105.121 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1066352517 63.184.105.121 (Thu, 16 Oct 2003 18:01:57 PDT) NNTP-Posting-Date: Thu, 16 Oct 2003 18:01:57 PDT Xref: archiver1.google.com comp.lang.ada:1037 Date: 2003-10-17T01:01:57+00:00 List-Id: CheGueVerra wrote: > Okay, after playing with it some more, I found that if I do this > > Put_line("Enter a number"); > Entiers.get(Number, 2); > Skip_line; > Put_line("Enter a string"); > Get_Line(TstStr, Last); > Put_line(TstStr(TstStr'First..Last)); Good. You've fixed the Put_Line, which before was displaying the entire string. > > > then the program runs as I expect it to do, the thing is I don't understand > why I need a Skip_line for it to work, So if anyone can shed some light on > that I would appriciate it You had 2 lines: 1 with a number, and one with a string. Integer_IO.Get gets the number. It does not skip the line terminator. The Skip_Line does that. Without the Skip_Line, your Get_Line gets the null string left on the number's line and skips that line terminator. Things get even worse if you make an error entering the number. Try entering "X" for the number and see what you get. For this reason, getting numeric input is usually best done be getting a string, then using 'Image or Get from the numeric IO packages in Text_IO to extract the number. This should be done inside a block to handle exceptions from illegal input, and that should be inside a block to give the user multiple tries to get it right. -- Jeff Carter "Perfidious English mouse-dropping hoarders." Monty Python & the Holy Grail 10