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,4f316de357ae35e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-01 09:09:17 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dennison@telepath.com (Ted Dennison) Newsgroups: comp.lang.ada Subject: Re: FAQ and string functions Date: 1 Aug 2002 09:09:17 -0700 Organization: http://groups.google.com/ Message-ID: <4519e058.0208010809.6a4c5e22@posting.google.com> References: <20020730093206.A8550@videoproject.kiev.ua> <4519e058.0207300548.15eeb65c@posting.google.com> <29e5ffff.0207302052.465a3193@posting.google.com> NNTP-Posting-Host: 65.115.221.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1028218157 18273 127.0.0.1 (1 Aug 2002 16:09:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 1 Aug 2002 16:09:17 GMT Xref: archiver1.google.com comp.lang.ada:27578 Date: 2002-08-01T16:09:17+00:00 List-Id: bam@snoopy.apana.org.au (Brian May) wrote in message news:<29e5ffff.0207302052.465a3193@posting.google.com>... > I have two questions concerning strings that I can't find answers for > in the RM: > > 1. How do I split a string up into tokens and iterate through the list > of tokens (compare with C's strtok function)? The analogous routine is Ada.Strings.*.Find_Token (where * is your choice of "Fixed", "Bounded", or "Unbounded"). > 2. Can this ugly looking code be simplified? > > declare > I : Iterator; > begin > I := Element_Iterator(Class_Element,"parent"); > while More(I) loop > declare > My_Node : Node renames Value(I); > Class_Ref : DOM_String renames > Get_Attribute(My_Node,"ref"); > begin > Put_Line(Class_Name(Package_Id,Class_Ref)&"($1,$2,$3)"); > end; > Next(I); > end loop; > Free(I); > end; I'm not a big fan of these kinds of renames. Why not instead just write: Put_Line (Class_Name (Package_ID, Get_Attribute (Value (I), "ref")) & "($1,$2,$3)"); I think that's much easier to read than your 4 line (semicolon) declare block. If you insist in splitting it up, turn those renames into constants. I'd still skip the "My_Node" one, unless you are going to use it in more than one place.