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,decb0c44a2cbd5dc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-01 07:59:40 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dennison@telepath.com (Ted Dennison) Newsgroups: comp.lang.ada Subject: Re: How to delete charcters in a string? Date: 1 Feb 2002 07:59:39 -0800 Organization: http://groups.google.com/ Message-ID: <4519e058.0202010759.43b26a19@posting.google.com> References: <4519e058.0201310647.3637d7a9@posting.google.com> <3C596BE4.D0F1BFCB@otelco.net> NNTP-Posting-Host: 65.115.221.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1012579180 2628 127.0.0.1 (1 Feb 2002 15:59:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 1 Feb 2002 15:59:40 GMT Xref: archiver1.google.com comp.lang.ada:19484 Date: 2002-02-01T15:59:40+00:00 List-Id: Larry Hazel wrote in message news:<3C596BE4.D0F1BFCB@otelco.net>... > Good points Ted. It caused me to wonder. Since a null character in Ada means > (essentially) "no character here", rather than end of string, could you just > replace the character you want to delete with a null character? If it truly means that. If you are writing the program that will process the string, then you can certinaly make it mean that. But that doesn't mean that "Foo" & ASCII.NUL = "Foo" will return true. So they are *not* the same in that sense. How a device (like a terminal display) will handle a nul is up to it. That's not the point though. Since C's strings are somewhat dynamic, using them as storage while the contents are massaged into proper place is encouraged. Thus algorithms that cause string values to be modified are fairly natural in C. In Ada its usualy much more sensible (and possible) to figure our your string's final value in one shot. If you need intermediate steps, you'd usually want to use intermediate strings. So algorithms that rely on mucking with string values in place are discouraged. My point is that one shouldn't try solving problems the C way in Ada. As they say at NASA, "Never apply a Star Trek solution to a Babylon 5 problem". Newbies are quite likely to fall into such a trap, and I haven't seen this one give his rationale for needing a "delete one character" solution so that I can believe otherwise. So the first answer here shouldn't be "here's how you do that...", it should be "Why do you need to do that?" -- T.E.D. Home - mailto:dennison@telepath.com (Yahoo: Ted_Dennison) Homepage - http://www.telepath.com/dennison/Ted/TED.html