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

Arthur Flexser flexser at fiu.edu
Thu Jun 1 17:31:18 EDT 2006


There is actually a genuine bug in the way CoCo Basic processes FOR/NEXT.  It
was in fact the subject of an article in Byte in the early 80s because the same
bug occurs in various other Microsoft Basics as well.  My memory is a bit hazy
on the details, but here's what I recall;  perhaps someone here can concoct a
Basic program that illustrates the bug.  I believe that the bug produces a
spurious ?NF (NEXT without FOR) error.  I did once encounter it in a program I
wrote, soon after I bought my CoCo and before seeing the Byte article;  I called
Tandy about it (back in those days they actually had phone support), but the
techie I spoke with was stumped, not surprisingly.

The bug occurs when you exit an initial FOR/NEXT loop without completing it
(which is perfectly legal to do) and then reuse the same loop variable name in a
later loop.  It is critical that the NEXT statements contain the variable name
(i.e., NEXT Z, not just NEXT) for the bug to occur.  I think maybe the variable
that was previously used in an inner loop must be used later in an outer loop,
or possibly vice versa.  As I said, my memory is pretty vague on this, even
though I did at one time trace the source of the bug in the ROM code.

Anyone want to fiddle around with coming up with some code that produces the
spurious ?NF error?

Art 




More information about the Coco mailing list