[Color Computer] [Coco] Bug in FOR NEXT ?
Robert Gault
robert.gault at worldnet.att.net
Thu Jun 1 07:37:47 EDT 2006
It is not unique but depends on the structure of the loop. A FOR/NEXT
loop has the test as part of the FOR portion and the variable update as
part of the NEXT. Therefore the loop can't exit until A=11 for the case
below.
A=10: FOR=true: (process loop internal, if any): NEXT A=A+1: A=11:
FOR=false: exit loop
James Diffendaffer wrote:
> Congratulations... you just discovered the most common test question
> from any BASIC programming class.
> It would list a program like that and ask what the output was.
> In other words... that's not unique to the Coco.
>
>
>>I can't believe that after +20 years with the CoCo I never got into
>>this... weird.
>>Thanks
>>
>>
>>Benoit Bleau wrote:
>>
>>
>>>Diego,
>>>That's not a bug... In (at least the coco) basic, the "for-next"
>>>variable contains +1 at the end of the loop.
>>>Try this:
>>>10 FOR A=1 to 10: NEXT
>>>20 PRINT A
>>>
>>>This should print 11.
>
>
>
>
>
>
>
More information about the Coco
mailing list