From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: string manipulation
Date: Sun, 08 Dec 2002 02:24:39 GMT
Date: 2002-12-08T02:24:39+00:00 [thread overview]
Message-ID: <3DF2AD96.6010100@acm.org> (raw)
In-Reply-To: ynvI9.27498$Mn4.329910@wagner.videotron.net
Gep wrote:
>
> while not valid
> loop
> get_line(V_string, V_length);
>
> if V_length= V_string'length then
> Skip_Line;
> Valid := True;
> else
> valid :=false;
> Put("invalid");
> end if;
> end loop;
This looks better then that other code. You can do this. It will
repeatedly get a line until it gets one that is exactly V_String'Length
characters. If that's what you want. I don't see what it has to do with
declaring a string variable of a specific length.
Valid is sort of useless here, as well as providing an opportunity for
errors. You can forget to assign to it, or assign the wrong value. I
think this would read better without it:
loop
Get_Line (...);
if V_Length = V_String'Length then
Skip_Line;
exit;
end if;
Put ("invalid");
end loop;
The purpose of the code is to exit the loop when a line of the right
length is read. It's better for the code to say that, then to hide it
behind a Boolean flag.
--
Jeff Carter
"Pray that there's intelligent life somewhere up in
space, 'cause there's bugger all down here on earth."
Monty Python's Meaning of Life
next prev parent reply other threads:[~2002-12-08 2:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-07 23:14 string manipulation Gep
2002-12-07 23:20 ` Gep
2002-12-08 2:24 ` Jeffrey Carter [this message]
2002-12-08 18:34 ` Gep
2002-12-08 14:02 ` Marin David Condic
2002-12-08 0:07 ` Jacob Sparre Andersen
2002-12-08 0:12 ` James S. Rogers
-- strict thread matches above, loose matches on Subject: below --
1998-09-22 0:00 String Manipulation SiliconJesus
1998-09-23 0:00 ` David C. Hoos, Sr.
1998-04-08 0:00 Howard Davies
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox