gobasic icon indicating copy to clipboard operation
gobasic copied to clipboard

Suppose for NEXT without variable

Open udhos opened this issue 6 years ago • 1 comments

gobasic should support NEXT without a variable.

The NEXT variable should be optional unless for BASIC code collapsing multiple FOR loops into the same NEXT (10 for a=1 to 2: for b=3 to 5: next b,a).

Documentation: https://hwiegman.home.xs4all.nl/gw-man/FORNEXT.html

$ gobasic next.bas 
1Error running program:
	Line 30 : Expected IDENT after NEXT in FOR loop, got Token{Type:NEWLINE Value:\n}
$ 
$ more next.bas 
10 for i=1 to 3
20 print i
30 next

udhos avatar Jan 25 '19 19:01 udhos

Some BASICs allow this. e.g. visual-basic:

  • https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/for-next-statement

Some BASIC implementations do not.

  • e.g. ZX Spectrum

When I've been in doubt, I've gone with the latter approach.

skx avatar Jan 25 '19 19:01 skx