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

Rod Barnhart rod.barnhart at gmail.com
Thu Jun 1 08:02:26 EDT 2006


It makes perfect sense that the Basic for-next works the same as the C for
does, but in all my years of programming, I don't think I've ever been
taught or come across that. I guess you can teach an old programmer new
tricks.

Rod


On 6/1/06, William Astle <lost at l-w.ca> wrote:
>
> 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?
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
>



-- 
Rod Barnhart aka Wintermute (http://www.nitemarecafe.com)

NOTICE: Due to Presidential Executive Orders, the National Security Agency
may have read this email without warning, warrant, or notice. They may do
this without any judicial or legislative oversight. You have no recourse nor
protection save to call for the impeachment of the current President.


_____________________________________________________________

Linux World Net: A Linux Blog Network
http://www.linuxworldnet.com



More information about the Coco mailing list