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,794c64d1f9164710 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-21 16:32:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.visi.com!hermes.visi.com!nnxp1.twtelecom.net!news-east.rr.com!news-west.rr.com!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: functions, packages & characters Date: Thu, 21 Feb 2002 19:37:49 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <20020221130715.12738.00000034@mb-bg.aol.com> <3C753C66.8020509@mail.com> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:20238 Date: 2002-02-21T19:37:49-05:00 List-Id: "Randy Brukardt" wrote in message news:u7b1g6cooeo49@corp.supernews.com... > It is possible to write such a > Get_Line out of the primitives in Text_IO, but the result would be > unacceptably slow (because you would have to read a character at a > time - you can't use Get_Line because you can't tell between the case of > a line which exactly fills the buffer and a line which is too long and > does not -- but in the former case, the line terminator is skipped). This statement is incorrect. You can test for this case via the predicate: if Last < Line'Last then --means we've consumed all the input Which means you can make your input buffer as large as you like. In general, you should use Get_Line this way: declare Max : constant := 80; --or whatever Line : String (1 .. Max + 1); --note value of Line'Last Last : Natural; begin loop Get_Line (Line, Last); --do something with Line (Line'First .. Last) exit when Last < Line'Last; end loop; end; You can search comp.lang.ada at google.com for several posts I've written on this very subject (search for "get_line"). --STX with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Test_Get_Line is Max : constant := 10; Line : String (1 .. Max + 1); Last : Natural; Buffer : Unbounded_String; begin Put ("ready: "); loop Get_Line (Line, Last); Append (Buffer, Line (Line'First .. Last)); exit when Last < Line'Last; end loop; Put_Line ("line is '" & To_String (Buffer) & "'"); end Test_Get_Line;