From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,364deb6698b494cb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-01 07:44:24 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <4713a80b.0106010531.7f6f4da8@posting.google.com> Subject: Re: Ada String Issue: String within Strings Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Fri, 01 Jun 2001 10:43:35 EDT Organization: http://www.newsranger.com Date: Fri, 01 Jun 2001 14:43:35 GMT Xref: archiver1.google.com comp.lang.ada:7975 Date: 2001-06-01T14:43:35+00:00 List-Id: 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