From: Jeffrey Carter <spam@spam.com>
Subject: Re: I wish I could ...
Date: Fri, 17 Sep 2004 07:28:08 GMT
Date: 2004-09-17T07:28:08+00:00 [thread overview]
Message-ID: <cmw2d.57$qA6.16@newsread3.news.pas.earthlink.net> (raw)
In-Reply-To: <MHk2d.3400$d5.26018@newsb.telia.net>
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
prev parent reply other threads:[~2004-09-17 7:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-16 18:11 I wish I could Björn Persson
2004-09-16 18:20 ` Frank J. Lhota
2004-09-16 19:04 ` Björn Persson
2004-09-17 7:28 ` Jeffrey Carter [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