comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Ada String Issue: String within Strings
Date: Fri, 01 Jun 2001 15:07:01 GMT
Date: 2001-06-01T15:07:01+00:00	[thread overview]
Message-ID: <pcOR6.627$v4.20295@www.newsranger.com> (raw)
In-Reply-To: rSNR6.592$v4.18766@www.newsranger.com

In article <rSNR6.592$v4.18766@www.newsranger.com>, Ted Dennison says...
>Ada.Text_IO.Get_Line (f_From, LineItem, Index);
>while (not Ada.Text_IO.End_Of_File(f_From)) loop
>Found := 0;
>Found := Ada.Strings.Fixed.Index (LineItem(1..Index), Catch);
>if Found > 0 then
>Ada.Text_IO.Put_Line(f_To, LineItem(1..Index));
>end if;
>end loop;	

Yikes! Please ignore my lack of formatting. That was my posting software
speaking, not me.

To answer your other question: yes, you do seem to be going about this the right
way. The only other "peer review" comment I would make is:

The two assignments into "Found" (and thus the "Found" variable itself) are
unnessecary. You could remove them both and change the if statement to:

if Ada.Strings.Fixed.Index (LineItem(1..Index), Catch) > 0 then

Some might leave in the second assignment, but the first is completely unneeded.

Also, it appears that you are not reading from the file within the loop. That
means that the file pointer will not advance, and thus you will never reach the
end of the file (unless the very first read gets you there), and thus the loop
will iterate endlessly.

Also, if the first read *does* read the only line in the file, the contents of
what it read will never be checked.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



      reply	other threads:[~2001-06-01 15:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01 13:31 Ada String Issue: String within Strings Xcalibre
2001-06-01 14:04 ` Mark Johnson
2001-06-01 17:43   ` tmoran
2001-06-01 14:04 ` James Rogers
2001-06-01 14:43 ` Ted Dennison
2001-06-01 15:07   ` Ted Dennison [this message]
replies disabled

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