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,2f2ae3c6286f407b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-11-03 07:20:07 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!hermes.visi.com!news-out.visi.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Tokenizing a string in Ada Date: Fri, 03 Nov 2000 15:06:23 GMT Organization: Deja.com - Before you buy. Message-ID: <8tuk98$c7k$1@nnrp1.deja.com> References: <20001103063537.25697.00000237@ng-mf1.news.cs.com> NNTP-Posting-Host: 204.48.27.130 X-Article-Creation-Date: Fri Nov 03 15:06:23 2000 GMT X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) 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:1748 Date: 2000-11-03T15:06:23+00:00 List-Id: In article <20001103063537.25697.00000237@ng-mf1.news.cs.com>, rbbaldwin8@cs.com (Rbbaldwin8) wrote: > I need to read lines from a text file which consist of a mixture of > strings and numeric values separated by commas and use these values in > the application. The format of each line is the same as far as which > data is in each position. I think the safest way to do this is to read > each line into a fixed-length string, then split it at the commas. > Strings in the CSV lines are not quoted but do not contain commas > within the strings. > How can I do this in Ada. I can't find a string function like C's > strtok or TCL's split, or am I misssing something. Check out the Ada.Strings.* packages. In particular, look at Ada.Strings.Fixed.Index and Ada.Strings.Fixed.Find_Token. While you are at it read entirely through LRM annexes A, L, and K. If you don't have an LRM, you can borrow ours at http://www.ada-auth.org/~acats/arm-html/RM-TOC.html :-). There's lots of goodies in there that every Ada programmer need to know about. If you are going to have to do this kind of thing a lot, you may want to look into OpenToken ( http://www.telepath.com/dennison/Ted/OpenToken/OpenToken.html ). I use it to tokenize at least 3 different kinds of .csv files, along with a couple other configuration files on the project I'm working on now. It alreay has a predefined token type for CSV "strings" (as you call them). -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy.