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,4c049fca34123e80 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-13 03:44:48 PST Message-ID: <3B77AEAF.72F868DC@amsjv.com> Date: Mon, 13 Aug 2001 11:40:47 +0100 From: Des Walker Organization: Alenia-Marconi Systems X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Variable length string References: <9l82gv$j83$1@news.mch.sbs.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: farwkn6911.frlngtn.gecm.com X-Trace: 13 Aug 2001 11:34:28 GMT, farwkn6911.frlngtn.gecm.com Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news-raspail.gip.net!news.gsl.net!gip.net!grolier!btnet-peer0!btnet-feed5!btnet!newreader.ukcore.bt.net!pull.gecm.com!farwkn6911.frlngtn.gecm.com Xref: archiver1.google.com comp.lang.ada:11838 Date: 2001-08-13T11:40:47+01:00 List-Id: Shitij wrote: > > Hi, > Iam new to ADA.I just wanted to know how do you define a variable length > string.I have declared a string array of length say a size of 20.But if I > use get and pass this string as an arguement,then unless and until I fill > this with exactly 20 characters my program is not working.How to overcome > this? > Iam using the below structure > > type list; > type pList is access list; > type list is > record > data:integer; > str:string(1 .. 20); > next:pList:=NULL; > end record; Hi, I think the Text_Io Get procedure attempts to get as many characters as the length of the supplied string and this can include multiple line feed characters. If you expect to input a single line of text you could use the Get_Line procedure. This returns the index in the string of the last character read, and you could store this information in your record so that you could always access the appropriate slice of your string. Alternatively, you could try using unbounded strings, they're a little weightier on performance compared to standard strings, but keep track of the length for you. An example of their use can be found through Section 8 of the Lovelace Tutorial. http://www.adahome.com/Tutorials/Lovelace/lovelace.html select the link of 'The master outline of all lessons' Regards Des Walker