robhagemans / pcbasic

PC-BASIC - A free, cross-platform emulator for the GW-BASIC family of interpreters
http://www.pc-basic.org
Other
396 stars 48 forks source link

Can't load program that starts with a comment #127

Closed chadwhitacre closed 3 years ago

chadwhitacre commented 3 years ago

Steps

  1. Write a program that starts with a comment.
  2. load"test"

Expected

Ok

Actual

Direct statement in file
Ok

Works

10 PRINT "Greetings, program!"

Doesn't Work

' comment
10 PRINT "Greetings, program!"

Notes

PC-BASIC version: 1.2.14 Operating system version: macOS 10.13.6 (17G10021)

robhagemans commented 3 years ago

Hi Chad, that's expected behaviour - in GW-BASIC every line must have a line number, including comments; if not, you'll get a Direct statement in file error. Your program will work in QBASIC but not in GW-BASIC or PC-BASIC. For it to work you would have to write instead:

5 ' comment
10 PRINT "Greetings, program!"
chadwhitacre commented 3 years ago

Thanks @robhagemans. In that case, it's curious that this program seems to work:

10 PRINT "Greetings, program!"
' comment

Any explanation?

robhagemans commented 3 years ago

PC-BASIC 1.2 reads that in as the continuation of line 10 with an LF - note how LIST 10 will show both lines. This is no longer standard in 2.0 where you'll just get Direct statement in file in this case, unless you set the --soft-linefeed option on startup.

Note that that program actually leads to really weird behaviour in GW-BASIC where it continues to add keyboard input to the program listing. That's not something that makes much sense to try to reproduce, so the "correct" behaviour is basically undefined.