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,d955a56d21742fee X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-19 16:13:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <3ce7c19a@news.comindico.com.au> <3ce81da1$1@news.comindico.com.au> Subject: An example was Re: Tokens X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Mon, 20 May 2002 00:13:12 +0100 NNTP-Posting-Host: 62.255.157.109 X-Complaints-To: abuse@ntlworld.com X-Trace: news6-win.server.ntlworld.com 1021849993 62.255.157.109 (Mon, 20 May 2002 00:13:13 BST) NNTP-Posting-Date: Mon, 20 May 2002 00:13:13 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:24392 Date: 2002-05-20T00:13:12+01:00 List-Id: "ProLogic" wrote in message news:3ce81da1$1@news.comindico.com.au... > Could I you show me a working example of this please? I've read that entire > section you have shown me, hmmm This is a quicky example I wrote in 10mins. It uses recursion which I think is clearer in this example, but if it's not clear what is going on I'll rewrite it with a loop no bother. If OE mangles it, send me an email (change spamoff to chris) HTH, Chris with ada.strings.fixed; -- find_token is here; with ada.strings.maps; -- character_set is here; with ada.text_io; use ada.strings; -- outside/inside are here; procedure token_example is -- prints all the "words" in a string, where -- delims is the set of characters regarded as whitespace. -- procedure what_words (str : in string; delims : in maps.character_set) is first : positive := 1; last : natural := 0; begin fixed.find_token (str, delims, ada.strings.outside, first, last); -- if last = 0 there are no more tokens, so we stop, -- otherwise we recur! -- if last > 0 then ada.text_io.put (str(first..last) & " & "); what_words (str (last + 1..str'last), delims); end if; end what_words; -- a simple character set! -- something_simple : maps.character_set := maps.to_set (" !?,"); begin what_words ("My name is bob! And I like skinny dipping parties how about you?", something_simple); end token_example;