skx / gobasic

A BASIC interpreter written in golang.
https://blog.steve.fi/tags/basic/
GNU General Public License v2.0
323 stars 27 forks source link

INPUT prompt string should be optional #81

Open udhos opened 5 years ago

udhos commented 5 years ago

I think INPUT without prompt string should be supported.

$ more input.bas
10 input a : print a
$ 
$ gobasic input.bas
Error running program:
    Line 10 : ERROR: INPUT should be : INPUT "prompt",var
$ 
skx commented 5 years ago

All the versions of BASIC I'm familiar with expect a prompt. For example:

I think this is a matter of opinion, because you can receive the same result via:

 INPUT "", a

(Plus this avoids confusion if we were ever to allow multiple-inputs. e.g. "INPUT a, b" - does that mean read two input values? Or does it mean print the prompt from variable a, into variable b ?)

udhos commented 5 years ago

In at least this BASIC dialect, the prompt string is optional: http://www.antonis.de/qbebooks/gwbasman/input.html

Also, there are those old games using INPUT with no prompt string: http://www.vintage-basic.net/bcg/mathdice.bas 520 INPUT T1

According to those games, "INPUT a, b" would mean to collect two numeric variables separated with comma:

10 input a,b: print a"-"b
  run
  ? 2,3
   2 - 3
udhos commented 5 years ago

Just for the records, it seems ZX Spectrum supported INPUT without prompt string:

100 REM this polite program remembers your name
110 INPUT n$
120 PRINT "Hello ";n$;"!"
130 GO TO 110

http://www.worldofspectrum.org/ZXBasicManual/zxmanchap2.html