comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Extracting Fields in Files
Date: 2000/01/13
Date: 2000-01-13T19:09:24+00:00	[thread overview]
Message-ID: <85l7t4$18c$1@hobbes2.crc.com> (raw)
In-Reply-To: 85l0iu$6uj$1@nnrp1.deja.com


<jmoor@my-deja.com> wrote in message news:85l0iu$6uj$1@nnrp1.deja.com...
> Would you believe that I am reading a variable length record created on
> a Unisys machine whose records are in the following sequence:
>
> record    size
>   #       (bytes)
>
> 1          16
> 2         212
> 3          16
> 4         212
> 5          16
> 6         212
> 7          16
> 8         212
> 9          16
>
> I open the file with the following statement;
>   text_io_open ( file => tip0125,
>        mode => text_i.in_file,
>        name => "tip0125");
>
> Every time I read the file with the following statement;
>   get_line (file => tip0125,
>       item => rec01,
>       last => rec01_length,)
>
> After each 212 byte record is read, the get_line goes through a cycle
> where it believes a zero byte record has been read.  I can easily get
> around the problem by testing "rec01_length" for zero bytes, but this
> is evidence that I might not understand the nature of the "get_line"
> command when reading a variable length file.
Well.... Ada doesn't really speak of file "records," as such.

Ada.Text_IO.Get_Line reads based on whatever the line terminator is
for the OS in question.  Reading a file on an OS with a different line
termination convention may produce unexpected results.

You may find it more useful to use Ada.Streams.Stream_IO, because it
allows you to read the file as a stream of bytes -- in which case you can
do your own thing to recognize line terminators.

From your earlier post it appeared that your code also depended on
the fields beginning and ending in specific columns.  You may find
the procedures like Ada.Strings.Fixed.Find_Token helpful in breaking
a line up into tokens if the fields are always delimited by characters
that never appear within any field.








  reply	other threads:[~2000-01-13  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-13  0:00 Extracting Fields in Files Christoph Grein
2000-01-13  0:00 ` jmoor
2000-01-13  0:00   ` David C. Hoos, Sr. [this message]
2000-01-14  0:00     ` jmoor
2000-01-14  0:00       ` Ted Dennison
2000-01-15  0:00       ` Gautier
  -- strict thread matches above, loose matches on Subject: below --
2000-01-14  0:00 Christoph Grein
2000-01-14  0:00 ` jmoor
2000-01-12  0:00 jmoor
replies disabled

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