comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent <daemon2@internet.lu>
Subject: Re: Reading data from file
Date: Wed, 5 Mar 2014 12:33:16 -0800 (PST)
Date: 2014-03-05T12:33:16-08:00	[thread overview]
Message-ID: <df64ee54-cb10-41a6-8521-39a1ca46291b@googlegroups.com> (raw)
In-Reply-To: <u4odG4BP3yFTFwZb@ada-augusta.demon.co.uk>

Am Dienstag, 4. März 2014 22:42:37 UTC+1 schrieb Niklas Holsti:

> Also try to configure your news-reader to break the lines in your 
> postings to some reasonable length, say 70 characters. Commenting is
> difficult if you post messages with very long lines, at least in my
> news-reader (Thunderbird).

I don't use a news-reader so difficult to configure.
I will try to limit my postings to 1/2 the width.

>So the problem is that after reading the ID you must 
>move the read point to the start of the "name" line. 
>Add a Skip_Line between the Get(ID) and 
>the Get_Line(Name). 

The Skip_Line works only if I use it together with:

Ada.Text_IO.Get (File => Import_File, Item => Temp_Record.Name);

and this only if I put spaces after "test" to a total length of 30 chars.
I suppose the spaces are needed because the name is defined as:

   MaxName : constant Positive := 30;
   subtype NameType is String (1 .. MaxName);

Get_Line w/ or w/o Skip_Line fails with the same error 
independently of the number of spaces behind the name.

Even tried this:

declare 
       S : String := Ada.Text_IO.Get_Line(File => Import_File);
        begin
            Temp_Record.Name (1 .. S'Length) := S;
         end;

Works w/o the (File => Import_File). Then it waits for
keyboard input and everything is fine. If it tries to read
from file then not.

Until now I like Ada very much but this odd behavior
of Ada.Text_IO.Get/Get_Line drives me crazy.

The integer/enumeration getters aren't so picky.

@ Mike H

>If you don't believe me, try putting a non-numeric 
>character in the "ID" line.

Doesn't even need to be non-numeric. ID needs to be
in range 1111..9999.

The Insert procedure from keyboard is robust and 
won't continue until every field is entered correctly.

Just began the read from file procedure. Would be
happy if that worked. Then I will take care of robustness.

>Do not take that as a criticism ...

I'm an noob so criticism is quite welcome. I don't
earn my money as programmer and probably this
never happens so there are a lot of things I don't know. 
It will help me improve my code, style or whatever.

Thanks

Laurent


  reply	other threads:[~2014-03-05 20:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04  9:46 Reading data from file Laurent
2014-03-04 16:17 ` adambeneschan
2014-03-04 18:08 ` Mike H
2014-03-04 21:27   ` Laurent
2014-03-04 21:35     ` Laurent
2014-03-04 21:42     ` Niklas Holsti
2014-03-05 13:59     ` Mike H
2014-03-05 20:33       ` Laurent [this message]
2014-03-05 21:00         ` Jeffrey Carter
2014-03-05 21:13           ` Laurent
2014-03-05 21:25             ` Niklas Holsti
2014-03-05 21:56               ` Laurent
2014-03-06  8:35                 ` Dmitry A. Kazakov
2014-03-07 21:55                   ` Laurent
2014-03-08  6:56                     ` Dmitry A. Kazakov
2014-03-08 21:21                       ` Laurent
2014-03-09 22:39                         ` Laurent
2014-03-10  2:42                           ` Jeffrey Carter
2014-03-11 20:54                             ` Laurent
2014-03-08  9:00                     ` Simon Wright
replies disabled

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