comp.lang.ada
 help / color / mirror / Atom feed
* Re: Tokenizing a string in Ada
  2000-11-03 15:06 ` Ted Dennison
@ 2000-11-03  0:00   ` Tom Hargraves
  2000-11-03  0:00     ` Larry Kilgallen
  2000-11-03  0:00     ` Ted Dennison
  0 siblings, 2 replies; 6+ messages in thread
From: Tom Hargraves @ 2000-11-03  0:00 UTC (permalink / raw)


Hi Ted,

This post is more akin to Franck's post 'binary tree and files', but since
you are promoting 'open token' I thought I'd post this here. [NB. I have not
had time to study Open Token, so maybe my answers are there]

Many many many times I have seen Ada (and other) programmers saving data
structures in files, the more astute save them in human readable form,
unless there is a pressing performance hit.

I have seen just as many different ways to save this data, from a variety of
tags, indenture, tuples etc. Is there not some standard way of doing this?
If there isn't should there be?

Is XML a standard we should choose? Seems to provide nesting, a flexible tag
schema, and freely available format checkers.

Are there any easy to use ada packages available to facilitate this?

Yours curiously,
Tom H.


"Ted Dennison" <dennison@telepath.com> wrote in message
news:8tuk98$c7k$1@nnrp1.deja.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.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tokenizing a string in Ada
  2000-11-03  0:00   ` Tom Hargraves
@ 2000-11-03  0:00     ` Larry Kilgallen
  2000-11-03  0:00     ` Ted Dennison
  1 sibling, 0 replies; 6+ messages in thread
From: Larry Kilgallen @ 2000-11-03  0:00 UTC (permalink / raw)


In article <3a030814@rsl2.rslnet.net>, "Tom Hargraves" <tharg@vtcinet.com> writes:

> I have seen just as many different ways to save this data, from a variety of
> tags, indenture, tuples etc. Is there not some standard way of doing this?
> If there isn't should there be?
> 
> Is XML a standard we should choose? Seems to provide nesting, a flexible tag
> schema, and freely available format checkers.

What "we" should use depends considerably on the problem domain in which
we are involved.

For me, the obvious choice ASN.1 DER.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tokenizing a string in Ada
  2000-11-03  0:00   ` Tom Hargraves
  2000-11-03  0:00     ` Larry Kilgallen
@ 2000-11-03  0:00     ` Ted Dennison
  1 sibling, 0 replies; 6+ messages in thread
From: Ted Dennison @ 2000-11-03  0:00 UTC (permalink / raw)


In article <3a030814@rsl2.rslnet.net>,
  "Tom Hargraves" <tharg@vtcinet.com> wrote:
> Many many many times I have seen Ada (and other) programmers saving
> data structures in files, the more astute save them in human readable
> form, unless there is a pressing performance hit.
>
> I have seen just as many different ways to save this data, from a
> variety of tags, indenture, tuples etc. Is there not some standard way
> of doing this? If there isn't should there be?

One of my favorite quotes of the new era is, "The best thing about
standards is that there are so many to choose from".

In many cases CSV is an ideal format for tabular data. There's no
offical ISO standard (that I know of), but its support is nothing short
of awesome. Its understood by nearly every spreadsheet and database
program, and by oddles of other data visualization and manipulation
tools. Plus, its fairly human readable.

Compare this with XML, which has a many dialects as developers, is only
understood by a few newer tools, and is about as human-readable as C
source code. Perhaps XML is a bit of a breakthrough for data that isn't
table-based, but its not a panacea.

I'd like to see someone submit XML recognizers for OpenToken, just so we
can say we have it. But apparently no-one has felt the need to build it
yet. CSV was one of the first things added.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Tokenizing a string in Ada
@ 2000-11-03 11:35 Rbbaldwin8
  2000-11-03 13:55 ` Florian Weimer
  2000-11-03 15:06 ` Ted Dennison
  0 siblings, 2 replies; 6+ messages in thread
From: Rbbaldwin8 @ 2000-11-03 11:35 UTC (permalink / raw)


Hello.  I'm new at Ada and have a problem in an application I need to write.  

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.

Thanks in advance for your help.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tokenizing a string in Ada
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Florian Weimer @ 2000-11-03 13:55 UTC (permalink / raw)


rbbaldwin8@cs.com (Rbbaldwin8) writes:

> 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.

Either do it manually (by iterating over the string), or use some of
the facilities in the Ada.Strings.Fixed package.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tokenizing a string in Ada
  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
  2000-11-03  0:00   ` Tom Hargraves
  1 sibling, 1 reply; 6+ messages in thread
From: Ted Dennison @ 2000-11-03 15:06 UTC (permalink / raw)


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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-11-03 15:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2000-11-03  0:00   ` Tom Hargraves
2000-11-03  0:00     ` Larry Kilgallen
2000-11-03  0:00     ` Ted Dennison

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