agon-bbc-basic-adl icon indicating copy to clipboard operation
agon-bbc-basic-adl copied to clipboard

Unexpected "No such variable at line ..." and "Syntax error at line ..." error messages when BASIC DATA statement has a colon character

Open tonedef71 opened this issue 2 years ago • 1 comments

When run, the following code results in a No such variable at line 110 error:

100 REPEAT
110   READ A%
120 UNTIL A% = 255
130 DATA 1:REM
140 DATA 255

If you remove the REM from line 130 and re-run the program, then the "Syntax error at line 110` error message gets displayed instead.

If you next remove the : character from line 130 and re-run the program, then the program completes successfully as expected.

If you next remove line 140 and re-run the program, then the expected "Out of DATA at line 110" error message is displayed.

Within a DATA statement with valid data, if the BBC BASIC interpreter should encounter an : character, then the colon and all text that appears after should be ignored like a comment, except when the colon is enclosed within double quotation marks, as that colon is embedded within a string of text which happens to be an entry of String DATA.

I previously reported this as an issue in the Agon BBC Basic repo; as expected, this issue exists in the 24-bit ADL version of Agon BBC BASIC as well.

tonedef71 avatar Jan 09 '24 02:01 tonedef71

Note: Check whether this is a quirk of BBC BASIC for Z80 first.

  • BBC BASIC for Next: Get a 'No Such Variable at line 110' error message
  • BBC BASIC for CPM: As above

image

This looks like a quirk I've inherited from the original code.

NB:

  • There has been a change in the way REM statements are processed in BBC BASIC for Agon to accommodate international characters. This may account for the change in error message.
  • BBC BASIC for Z80 uses the same code for REM, DATA and DEF statements, so are ignored by the interpreter.
  • Looking at the READ code, I suspect it is taking 1:REM as an expression and is trying to evaluate it.

breakintoprogram avatar Jan 09 '24 20:01 breakintoprogram