The plot thickens…
First this code:
100 goto 1500
900 next i
910 print 910
920 goto 2000
1500 for i = 1 to 2
1510 print i
1520 goto 900
1530 next i
1540 print 1540
2000 rem
with these interpreters:
https://yohan.es/swbasic/
1
2
910
6800 FLEX BASIC
1
2
910
GWBASIC
1
NEXT without FOR in 900
Then this code:
100 goto 1500
900 next i
910 print 910
920 goto 2000
1500 for i = 1 to 0
1510 print i
1520 goto 900
1530 next i
1540 print 1540
2000 rem
with these interpreters:
https://yohan.es/swbasic/
1540
6800 FLEX BASIC
1
910
GWBASIC
1540
And then this code:
100 goto 1500
900 next i
910 print 910
920 goto 2000
1500 for i = 1 to 0
1510 print i
1520 goto 1700
1530 next i
1540 print 1540
1550 goto 2000
1700 next i
1710 print 1710
2000 rem
with these interpreters:
https://yohan.es/swbasic/
1540
6800 FLEX BASIC
1
1710
GWBASIC
1540
And finally this code:
100 goto 1500
900 next i
910 print 910
920 goto 2000
1500 for i = 1 to 2
1510 print i
1520 goto 1700
1530 next i
1540 print 1540
1550 goto 2000
1700 next i
1710 print 1710
2000 rem
with these interpreters:
https://yohan.es/swbasic/
1
2
1710
6800 FLEX BASIC
1
2
1710
GWBASIC
1
NEXT without FOR in 1700
Two different interpretations of “FOR I = 1 TO 0”:
- find the next “NEXT”; that is the bottom of the loop
- the loop always executes at least once
It is interesting that GWBASIC only considers the first NEXT following the FOR to be valid.