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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5c8805625bf2ecaa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: I wish I could ... References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Date: Fri, 17 Sep 2004 07:28:08 GMT NNTP-Posting-Host: 63.184.104.117 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1095406088 63.184.104.117 (Fri, 17 Sep 2004 00:28:08 PDT) NNTP-Posting-Date: Fri, 17 Sep 2004 00:28:08 PDT Xref: g2news1.google.com comp.lang.ada:3799 Date: 2004-09-17T07:28:08+00:00 List-Id: Bj�rn Persson wrote: > Right now I'm writing code like this in several places: > > case Going is > when Forward => > for Pos in 1 .. Source.Last loop > if Source.Reference.all (Pos) /= Character'Pos(Space) then > return Pos; > end if; > end loop; > when Backward => > for Pos in reverse 1 .. Source.Last loop > if Source.Reference.all (Pos) /= Character'Pos(Space) then > return Pos; > end if; > end loop; > end case; This looks like a function: function Find_Other (Source : Whatever; Item : Whatever_Else) return Thingy; Where Whatever is the type of Source in your code Whatever_Else is the type of Source.Reference (Pos) Thingy is the type of Pos You would also want a similar function that uses "=" rather than "/=": function Find_Equal (Source : Whatever; Item : Whatever_Else) return Thingy; Then all the cases where you're writing code like your example would be replaced by a call to one of these functions. It's probably more complicated than that. -- Jeff Carter "The time has come to act, and act fast. I'm leaving." Blazing Saddles 36