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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,248692b9d8756a39 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-18 04:45:05 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst!enst.fr!not-for-mail From: sk Newsgroups: comp.lang.ada Subject: Re: String slicing. Date: Mon, 18 Mar 2002 06:44:53 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1016455503 89518 137.194.161.2 (18 Mar 2002 12:45:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 18 Mar 2002 12:45:03 +0000 (UTC) Return-Path: X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19-4.3mdk i686) X-Accept-Language: en Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:21404 Date: 2002-03-18T06:44:53-06:00 Hi, If you are using Gnat, type "gnatpsta" at the command-line and you will be provided the following : type Integer is range -(2 ** 31) .. +(2 ** 31 - 1); subtype Natural is Integer range 0 .. +(2 ** 31 - 1); subtype Positive is Integer range 1 .. +(2 ** 31 - 1); ... type String is array (Positive range <>) of Character; pragma Pack (String); So in the simplest terms, a string is a numerically indexed array of characters. declare -- SB, SE --> String_Begins, String_Ends SB, SE : Natural := 0; Sample_String : constant String := "Hello Cruel World"; begin -- Find first ' ' for i in Sample_String'Range loop if Sample_String (I) = ' ' then SB := i; exit; end if; end loop; ... -- Pretend that the second ' ' has been found. TIO.Put_Line ( "The World is such a " & Sample_String (SB .. SE) & " place." ); end; In general, unless you are searching for control characters, specify them in the source or use named characters. For example, Html_Tag_Open : constant Character := '<'; Html_Tag_Close : constant Character := '>'; Horizontal_Tab : constant Character := Ada.Characters.Latin_1.HT; Also, you don't need to introduce the heavy-weight Ada.Strings.xxx unless your application is more complex than the one above. Even then, I personally just write small string-searchers within the application rather than introduce the Ada.Strings.xxx Hope this helps. -- ------------------------------------- -- Merge vertically for real address ------------------------------------- s n p @ t . o k i e k c c m -------------------------------------