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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8d3f28f2a74233d2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-30 09:20:18 PST Path: supernews.google.com!sn-xit-02!supernews.com!news-x.support.nl!portc03.blue.aol.com!newsfeed.skycache.com!Cidera!cpk-news-hub1.bbnplanet.com!news.gtei.net!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Newbie Questions about Get, Get_Line Date: Sat, 30 Dec 2000 17:09:27 GMT Organization: Deja.com Message-ID: <92l4s4$hjb$1@nnrp1.deja.com> References: NNTP-Posting-Host: 204.48.27.130 X-Article-Creation-Date: Sat Dec 30 17:09:27 2000 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001207 X-Http-Proxy: 1.0 x71.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:3468 Date: 2000-12-30T17:09:27+00:00 List-Id: In article , gressett@iglobal.net wrote: > What I would really find useful is a routine that could take a string > variable and fill it with terminal input with the following > properties: > > If the user input is shorter that the string variable, it will be > padded with blanks. Ewww. Why would you want that? Its soooo sloppy (not to mention wasteful). Plus it would significantly complicate dealing with the string later. If you want to insert that string in the middle of other strings, how are you going to do it? Just using "&" on a slice won't do the trick anymore, because you won't know the proper slice to use. If you really want this behavior, you can always do a: Str := (others => ' '); before the call, then ignore the return length. Better would be to use the return length to do the fill: Str (Last+1..Str'Last) := (others => ' '); > If the user input is longer than the string variable, the extra > characters should be thrown away, never to be seen again. There's nothing stopping you from writing a routine to do this yourself. It would only be about 3 lines of code (although handling *any* length would probably be a smidge more complicated, requiring a loop or recursion). But if I were you, I'd try to work with what the language gives me for a while. You should get used to Ada string handling before you go trying to fight it. Some have expressed a desire for a function that returns a perfectly-sized string, instead of the string-buffer and length interface. That would be more in keeping with the language (although you could only use it in certain circumstances). For an example of how to do that, see Martin Carlisle's entry on AdaPower at http://www.adapower.com/lang/recstring.html -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/