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.1 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,87a926dbf0cf8cb1 X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: newbie problem Date: 1998/12/07 Message-ID: <366C0409.E551CFBC@spam.innocon.com>#1/1 X-Deja-AN: 419679148 Content-Transfer-Encoding: 7bit References: <3667EE11.6E94BA0F@interact.net.au> Content-Type: text/plain; charset=us-ascii Organization: Innovative Concepts, Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-12-07T00:00:00+00:00 List-Id: Graeme Wallace wrote: > > If I want to get user input for my program in the form of a string of > undefined length, how do I do so ? If I set the string length to, say: > > help_me_please : String(1..20); > > I seem to be stuck with a string exactly that size. What is the > variable assignment which allows the actual length of the user input to > determine the length of the string which the io system > (ada.text_io.)gets ? > The way to do this is to use a function that returns a String: function Get_Line (File : Ada.Text_Io.File_Type := Ada.Text_Io.Current_Input) return String; Help_Me_Please : String := Get_Line; This will generally serve. You can obtain more flexibility at the price of more complexity by converting the result of the function to a variable-length string (Ada.Strings.Bounded or Ada.Strings.Unbounded). -- Jeff Carter E-mail: carter commercial-at innocon [period | full stop] com "Your mother was a hamster and your father smelt of elderberries." Monty Python & the Holy Grail