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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9e47ad8d460f46b8 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Extracting Fields in Files Date: 2000/01/13 Message-ID: <85l7t4$18c$1@hobbes2.crc.com>#1/1 X-Deja-AN: 572505318 References: <200001130658.HAA07055@bulgaria.otn.eurocopter.de> <85l0iu$6uj$1@nnrp1.deja.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@crc.com X-Trace: hobbes2.crc.com 947790564 1292 198.175.145.56 (13 Jan 2000 19:09:24 GMT) Organization: CRC: A wholly owned subsidiary of Thermo Electron NNTP-Posting-Date: 13 Jan 2000 19:09:24 GMT Newsgroups: comp.lang.ada Date: 2000-01-13T19:09:24+00:00 List-Id: 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.