richpl / PyBasic

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

Changes to input command #13

Closed JiFish closed 3 years ago

JiFish commented 3 years ago

To address 3 points:

  1. The documentation specifies that strings must be in quotes but this is NOT the case. And because the code expects it you can get unusual results:
    > 10 input a, b$, c
    > 20 print a, b$, c
    > run
    ? 1,bob,2
    1bob2
    > run
    ? 1,I'm "some "text",1
    1I'm some text1
    >

I have fixed this by formalising the current behaviour and allowing unquoted strings. A comment suggested python would add quotes automatically, but I couldn't get that to happen.

  1. It's annoying you can't collect strings with commas. Since input assumes you are entering a list of values. I fixed this by only splitting the input string n times, where n is the number of input variables.

  2. Now throws an error when the inputs aren't NAMEs.