comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Annoying behavior
Date: Sat, 25 Apr 2015 07:50:14 +0300
Date: 2015-04-25T07:50:14+03:00	[thread overview]
Message-ID: <cq0ko6Fj5dcU1@mid.individual.net> (raw)
In-Reply-To: <47c7df1e-17c1-44cb-a455-43431f0d39cd@googlegroups.com>

On 15-04-25 00:40 , Laurent wrote:
> Hi
>
> Trying to build a program which generates this type of txt files:

Irrelevant.

> For the moment I try to get the part done which generates the
> content in the middle of the file,

Irrelevant.

> The annoying behavior (for me, perhaps it is absolutely normal) I get
> is this while I try to read in the configuration file

The annoying behaviour (for me) is the way you are asking this 
question... half- :-)

> raised ANTIBIOTIQUES.NAME_TOO_SHORT : antibiotiques.adb:90

You should have showed the part of the program that raises this 
exception, and explained why you think it should NOT happen. Forcing us 
to download code from github is... annoying behaviour. At least, you 
should have put the github link at the start and explained why we should 
go there.

In summary, your configuration file consists of groups of lines of the form:

string Name, read with Text_IO.Get_Line
string Code_SIL, read with Text_IO.Get_Line
string CMI, read with Text_IO.Get_Line
literal SIR, read with an instance of Enumeration_IO.Get.

> So the first antibiotic is read but then something blows up.
> Has to to with the SIR which is an enumeration. The others are
> strings. If I remove the SIR's from the config file then all
> items are read.

This should have pushed you to look at (and show us) how you are reading 
in the SIR, which is with an instance of Enumeration_IO.Get.

> I am a bit lost because I don't understand what the reading
> procedure is getting to fail like this.

Text_IO.Get_Line reads the whole rest of the line, and then skips the 
line terminator.

Enumeration_IO.Get reads an enumeration literal, stops after the 
literal, and does NOT skip the line terminator.

Therefore, the next Get_Line sees only the line terminator, returns a 
null string, and then skips the line terminator. The null string leads 
to raising Name_Too_Short.

> Putting a Skip_Line behind doesn't help, makes things even worse.

Uncommenting your Skip_Line after the SIR_Type_IO.Get works perfectly 
for me, giving the output:

    Begin of reading loop
    read name: Amikacine
    read code: am
    read cmi: test
    read sir: S
    Begin of reading loop
    read name: Augmentin

and so on.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  parent reply	other threads:[~2015-04-25  4:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 21:40 Annoying behavior Laurent
2015-04-25  4:31 ` gautier_niouzes
2015-04-25  6:51   ` Laurent
2015-04-25  4:50 ` Niklas Holsti [this message]
2015-04-25  7:15   ` Laurent
2015-04-25  8:10     ` Niklas Holsti
2015-04-25 15:37       ` Laurent
2015-04-25 13:54 ` Stephen Leake
2015-04-25 15:46   ` Laurent
2015-04-25 17:02     ` Simon Wright
2015-04-25 17:41     ` Niklas Holsti
2015-04-25 18:58       ` Laurent
2015-04-25 19:30         ` Georg Bauhaus
2015-04-25 20:13           ` Laurent
2015-04-25 21:46             ` Laurent
2015-04-25 23:16           ` Bob Duff
2015-04-26 10:38     ` Jedi Tek'Unum
2015-04-26 11:52       ` Textedit and txt Laurent
2015-04-26 13:21         ` brbarkstrom
2015-05-06 21:23           ` Randy Brukardt
2015-05-07 21:12             ` Laurent
2015-05-07 21:48               ` Simon Wright
2015-05-07 22:24                 ` Laurent
2015-05-08  5:50                   ` Simon Wright
2015-05-08  7:35                     ` Laurent
2015-05-08 23:35               ` Randy Brukardt
2015-05-09 19:25                 ` Laurent
2015-05-09 21:36                   ` Anh Vo
2015-05-11 17:00                 ` Shark8
2015-05-11 17:49                   ` Dmitry A. Kazakov
2015-05-09 15:23               ` brbarkstrom
2015-05-12  1:10                 ` Randy Brukardt
2015-05-12 12:44                   ` brbarkstrom
2015-05-12 21:57                     ` Randy Brukardt
2015-05-13 12:07                       ` brbarkstrom
replies disabled

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