[Color Computer] [Coco] Bug in FOR NEXT ?

Kenneth Schunk ken.schunk at gmail.com
Sat Jun 3 06:31:31 EDT 2006


On 6/3/06, Willard Goosey <goosey at virgo.sdc.org> wrote:
> >Date: Thu, 1 Jun 2006 17:59:41 -0500
> >From: Frank Pittel <fwp at deepthought.com>
> >
> >I always that the loop counter was "undefined" outside the loop.
>
> That's a Pascal-ism, actually.
>
> The thing that surprised ME when I ran across it in BASIC is that
> FOR-NEXT loops always go through the loop at least once, even in cases
> like:
> 10 A=0
> 20 FOR B=1 TO A
> 30 REM DO SOMETHING
> 40 NEXT B
>
> Willard
> --
Yes, it's not obvious that the test is made in the NEXT statement, not
in the FOR statement. That's caught quite a few people. The Pascal
"Repeat ... Until" and "While" statements make it a bit more obvious
where the test is going to occur.

Ken

PS - sorry about the short message before - slip of the thumb on the
mouse button.



More information about the Coco mailing list