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 14:43:35 GMT
Date: 2001-06-01T14:43:35+00:00	[thread overview]
Message-ID: <rSNR6.592$v4.18766@www.newsranger.com> (raw)
In-Reply-To: 4713a80b.0106010531.7f6f4da8@posting.google.com

In article <4713a80b.0106010531.7f6f4da8@posting.google.com>, Xcalibre says...
>extract.adb:73:66: array type required in indexed component
>
>The code reads:
>   Get_Line (f_From, LineItem, Index);
>   while (not End_Of_File(f_From)) loop
>      Found := 0;
>      Found := Index (LineItem(1..Index), Catch);
>      if Found > 0 then
>	Put_Line(f_To, LineItem(1..Index));
>      end if;
>   end loop;	

It appears that the compiler is getting confused between your variable "Index",
and the subprogram "Index". In fact, your local declaration of the variable is
probably (silently) hiding the function.

This is one of the reasons why I *strongly* suggest that any beginner aviod the
"use" clause for packages. "use type" is generally OK, but "use" for packages is
very contraversial for exactly this reason: it can make things rather confusing.
Personally, I don't like to use it *ever*, but there are those who strongly
disagree with this policy. The safest thing for a beginner to do is to just
avoid the whole issue by using full notation for everything until you get enough
experience to make an intelligent decision on the issue yourself.

Try it yourself, and see what happens. The above turns into:

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;	




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



  parent reply	other threads:[~2001-06-01 14:43 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 [this message]
2001-06-01 15:07   ` Ted Dennison
replies disabled

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