fvdhoef / aquarius-plus

Official Aquarius+ repository
MIT License
45 stars 8 forks source link

Syntax error on valid command when reading .CAQ #75

Closed LoudScotsBloke closed 5 months ago

LoudScotsBloke commented 5 months ago

I get a syntax error when I load (or run) a .CAQ file that was created on either the OG Aquarius via USB BASIC or via any legacy emulator (VAQ or Aqualite). It seems to be when I have a SET FAST ON statement in the code. The issue is resolved if I re-type the line back in on the AQ+ itself, and save the file. The code runs perfectly after that. A couple of screen shots showing the issue...

Screenshot from 2024-06-09 20-40-14 Screenshot from 2024-06-09 20-40-01

fvdhoef commented 5 months ago

The SET FAST ON statement is plusBASIC specific. So if you type that in other BASIC versions it will be encoded as regular text instead of the correct plusBASIC tokens.

LoudScotsBloke commented 5 months ago

Hi. I know that set fast on is a plusbasic command. My code has clauses to only run those commands if an Aq+ is detected (and I am rubbing in a +). Those lines never run on the original Aquarius. If I retype the line, exactly the same... On the AQ+ it runs perfectly.

fvdhoef commented 5 months ago

I think you don't understand the point I'm trying to make. The binary CAQ format stores BASIC statements as tokens (single byte values), in the same way the program is stored in memory. So a statement such as PRINT is stored as a single byte instead of 5 characters. If you type a statement that is not recognized by BASIC as a statement it will be stored in full (not tokenized) as separate bytes (this is how variable names are stored). So if you enter the 'SET FAST ON' on the legacy BASIC it will be stored as separate bytes instead of 3 tokens. When you try to run that code on an Aq+ it will see that as a syntax error. When you retype the line it is tokenized by plusBASIC as 3 tokens and then it can recognize the statement.

Also, after you have retyped the line on plusBASIC and saved it again and would load that file on a regular Aquarius and list the said line it would not show as 'SET FAST ON' at all since Aquarius BASIC will not recognize the tokens.

LoudScotsBloke commented 5 months ago

Ahh... Thank you for that explanation. That does make my life a little more difficult when writing stuff for both legacy and plus though. But I get why it doesn't work now. Thank you.

LoudScotsBloke commented 5 months ago

I did also notice that the token is different for the Locate command. It seems to be translated to 'down'

LoudScotsBloke commented 5 months ago

Although it makes my development process a wee bit more involved... I understand why this happens, and I am happy to close the ticket.