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,18f7cf743c6dec5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-22 08:36:25 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!209.249.123.233.MISMATCH!xfer10.netnews.com!netnews.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!not-for-mail From: Marin David Condic Newsgroups: comp.lang.ada Subject: Re: Strings Date: Fri, 22 Dec 2000 11:35:15 -0500 Organization: Quadrus Corporation Message-ID: <3A4382C2.2595414@acm.org> References: <3A4362BD.8E156868@vdu.org> NNTP-Posting-Host: d1.56.b1.34 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 22 Dec 2000 16:33:34 GMT X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:3370 Date: 2000-12-22T16:33:34+00:00 List-Id: You'll want to investigate Ada.Strings.Unbounded. This lets you declare strings that are fully dynamic and can shrink/grow as you need it. It is not as efficient as Ada.Strings.Bounded (static allocation of a maximum size) or the plain vanilla type String, but unless you're operating in real time, this probably won't matter much. In Ada83, strings were essentially like C strings - a static array of characters. There weren't many utility routines to deal with them except the home grown variety. Ada95 retained this String type, but extended it to give you more choices about how to handle things and more utilities to do work for you. Most of the language still has parameters that require a String type, but it's simple enough to convert as you need to. My typical strategy is to read in whatever string data I need (using Text_IO or whatever else makes sense) and immediately convert to Unbounded_String for internal use. When it has to go out again, you just use the To_String function to get the data back to the correct data type for output. Once you get used to the subprograms and types involved, it isn't very hard at all. MDC Jef Kelmo wrote: > Hello, > > What I want is to figure how to get something like the C++ strings class, > where I can have strings of various sizes, eventually building an array of > strings. But I'm having trouble with a simple string itself. In C++, you have > the string.length which goes to the null character, but from what I can > figure, there is not the same thing in Ada. Is this true? > > Anyway, what I would like, as I mentioned, is to be able to create an > array of strings that I can feed, after its creation, with data and be able to > spit it back out to the screen with some simple way for it to understand the > length of each string. I found the Get_Line(Input, String, Last) thing, but do > I really have to keep track of that length for hundreds of strings? > > Thanks. > > Jef > > "Beard, Frank" wrote: > > > Jef, > > > > > I just want a usable string. How would I change the above code to do > > > this? And could someone please point me to a site that gives actual, > > > concrete examples of simple string use? > > > > While Ada.Strings.Bounded has some useful features, it goes a little beyond > > "simple" strings. -- ====================================================================== Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m Visit my web site at: http://www.mcondic.com/ "Giving money and power to Government is like giving whiskey and car keys to teenage boys." -- P. J. O'Rourke ======================================================================