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

William Astle lost at l-w.ca
Thu Jun 1 02:17:42 EDT 2006


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.

As a matter of fact, it's not unique to Basic either. Consider the 
following C code:

int x;
for (x = 1; x <= 10; x++) { /* do something */ }
printf("%d\n", x);

BTW, that's equivalent to:

FOR X=1 TO 10
REM do something
NEXT X
PRINT X

And, in fact, the two bits of code above will both print "11".

> 
>> 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.
> 
> 
> 
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor --------------------~--> 
> You can search right from your browser? It's easy and it's free.  See how.
> http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/CFFolB/TM
> --------------------------------------------------------------------~-> 
> 
> Brought to you by the 6809, the 6803 and their cousins! 
> Yahoo! Groups Links
> 
> <*> To visit your group on the web, go to:
>     http://groups.yahoo.com/group/ColorComputer/
> 
> <*> To unsubscribe from this group, send an email to:
>     ColorComputer-unsubscribe at yahoogroups.com
> 
> <*> Your use of Yahoo! Groups is subject to:
>     http://docs.yahoo.com/info/terms/
>  
> 
> 
> 
> 


-- 
William Astle
finger lost at l-w.ca for further information

Geek Code V3.12: GCS/M/S d- s+:+ !a C++ UL++++$ P++ L+++ !E W++ !N w---
!D !M PS PE V-- Y+ PGP t+@ 5++ X !R tv+@ b+++@ !DI D? G e++ h+ y?



More information about the Coco mailing list