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,9797292c79ff60c X-Google-Attributes: gid103376,public From: nobody@REPLAY.COM (Anonymous) Subject: Re: Assistance: Get/Get_line Date: 1998/05/22 Message-ID: <199805221422.QAA07806@basement.replay.com>#1/1 X-Deja-AN: 355559195 Content-Transfer-Encoding: 7bit References: <35645664.2AE1A75A@swl.msd.ray.com> X-001: Replay may or may not approve of the content of this posting X-002: Report misuse of this automated service to X-URL: http://www.replay.com/remailer/ Content-Type: text/plain; charset=us-ascii Organization: Replay Associates, L.L.P. Mail-To-News-Contact: postmaster@nym.alias.net Newsgroups: comp.lang.ada Date: 1998-05-22T00:00:00+00:00 List-Id: <355E0DE6.6867@info.polymtl.ca> <356231EB.3F2@eurocopter.de> On Thu, 21 May 1998 12:29:24 -0400, "John J Cupak Jr, CCP" wrote: [about using Text_Io to input Integers (or numbers in general)] > ... > Alternatively, if you use Get_Line(Line, Size) to read in the > entire line, then you can use the Integer Get from a string to > extract just the integer part (See RM A.10.8(15-16)): > > Get_Line(Line, Size); > Get(From => Line(1..Size), Item => Number, Last => Last); > ... This (or using 'Value) is similar to the approach I recommend. I either use a "function Get_Line return String;" or put if Size >= Line'Last then Skip_Line; end if; after the Get_Line. Then I'm sure the entire line is gone. If there is an error in the input, error handling is simplified if the line is gone. Using "Get (Number);" when there is an error in the input, the required error handling is difficult. I've seen many programs that do output prompt loop begin Get (Number); exit; exception when others => output "Invalid number; re-enter" end; end loop; that work fine when the input is correct. Type an "X" for the number and it goes into an infinite loop. Using Get_Line and really getting the entire line eliminates this common error. Jeff Carter PGP:1024/440FBE21 My real e-mail address: ( carter @ innocon . com ) "Now go away or I shall taunt you a second time." Monty Python & the Holy Grail Posted with Spam Hater - see http://www.compulink.co.uk/~net-services/spam/