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,5997b4b7b514f689 X-Google-Attributes: gid103376,public From: doucet@ripolin.laas.fr (Jean-Etienne Doucet) Subject: Re: Reading a line of arbitrary length Date: 1997/02/19 Message-ID: <5ef263$3oq@news.cict.fr>#1/1 X-Deja-AN: 219869306 Distribution: world References: <330319F1.41C67EA6@innocon.com> Organization: LAAS-CNRS, Toulouse (France) Reply-To: doucet@ripolin.laas.fr Newsgroups: comp.lang.ada Date: 1997-02-19T00:00:00+00:00 List-Id: About reading arbitrarily long strings, I've found (in a french book about Ada(83)) something like the following: with Ada.Text_IO; use Ada.Text_IO; function Get_Long_String return String is type Ref_String is access String; Buffer : Ref_String := new String'(""); Input : Character; begin -- Get_Long_String while not End_Of_Line loop Get (Input); Buffer := new String'(Buffer.all & Input); end loop; Skip_Line; return Buffer.all; end Get_Long_String; The question about storage usage was resolved by the fact that leaving the scope of the Ref_String type would free the storage used by the successive values of Buffer.all. I can't fully test it, because my installation can't support input lines longer than 255 characters :-( If you've got comments about this construct, I'd be happy to hear them. _______________________________________________________________________________ Jean-Etienne Doucet / LAAS-CNRS / Toulouse, France E-mail: doucet@laas.fr