richpl / PyBasic

Simple interactive BASIC interpreter written in Python
GNU General Public License v3.0
170 stars 46 forks source link

Don't stop PyBasic after a BASIC error? #66

Closed hlubenow closed 3 months ago

hlubenow commented 6 months ago

Hi,

thanks for creating PyBasic! I'm not really reporting an issue here. I just like to talk about something, I'd like to see in a future version of PyBasic: At the moment, when there's an error in the BASIC program, the Python code raises an error, and the Python script stops, exiting to the console. Now, I'm trying to combine PyBasic with Pygame, simulating the graphics of the C64 and such. The goal is, that in the end one (finally) can write BASIC programs in this simulation that are supposed to run about as fast as assembly programs on the 8-bit-computers. So I'd like to have a cursor in the simulation, and the user should be able to input the BASIC code. And when there's an error, the Python/Pygame environment shouldn't stop. Instead the user interface should for example print

?SYNTAX  ERROR
READY.

and continue running, waiting for the next user input. At the moment, as far as I can see, there are 87 raise-commands in PyBasic that stop the Python script in case of a BASIC error. Instead, I'd like it to print an error message to the console, and then to go on printing the next input prompt accepting more input. Would that be possible? It seems, I can't dig deep enough into your code yet to realize it myself.

Also, I'd like to see BASIC commands without line numbers being executed directly. You know, so that PyBasic accepts a simple

PRINT "Hello"

which it doesn't at the moment. That would also help a lot.

Thank you for your attention.

richpl commented 3 months ago

Hi, I'm glad you are making use of PyBasic. I'm not really supporting it any more but I'm very happy for people to fork the code and to make their own changes. My main emphasis is on trying to make the code robust (so that a faulty BASIC program doesn't just cause PyBasic itself to bomb out to the DOS prompt or whatever.