[Coco] Bug in FOR NEXT ?

Benoit Bleau benbleau at gmail.com
Wed May 31 23:56:42 EDT 2006


Diego Barizo wrote:
> I have a line like this:
> 1060 FOR A=1 TO 72:PRINT A:IF A$=B$ THEN GOSUB 2000: GOTO 1050  ELSE 
> NEXT A
> 1070 PRINT A
>
> The routine in line 2000 does not use  the variable A, and as 
> expected, the first PRINT A gives me 1 to 72
> BUT... The line 1070 gives me a value of 73.
> I'm clueless about this. Any ideas?
>
> Diego
>
>
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.

In your case, if I understand correctly, you're executing a subroutine 
if A$=B$, then you're starting the FOR loop again after that, right?
If that's what you wanted, in line 1070, A would be set to 73, because 
the condition A$=B$ was false for the 72 tries...

-Benoit




More information about the Coco mailing list