comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Tokenizing a string in Ada
Date: Fri, 03 Nov 2000 15:06:23 GMT
Date: 2000-11-03T15:06:23+00:00	[thread overview]
Message-ID: <8tuk98$c7k$1@nnrp1.deja.com> (raw)
In-Reply-To: 20001103063537.25697.00000237@ng-mf1.news.cs.com

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.



  parent reply	other threads:[~2000-11-03 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-03 11:35 Tokenizing a string in Ada Rbbaldwin8
2000-11-03 13:55 ` Florian Weimer
2000-11-03 15:06 ` Ted Dennison [this message]
2000-11-03  0:00   ` Tom Hargraves
2000-11-03  0:00     ` Larry Kilgallen
2000-11-03  0:00     ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox