Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I have learned something new: how to get a run-time syntax error
#2
You can.   You just need to separate it with a colon first.

Code: (Select All)
DATA 7: ' this is a comment

The issue you're seeing is that you're trying to read a string as a number, and that's the run-time error.

For example:

Code: (Select All)
DATA Hello World, Steve is Awesome, Steve's the best!

That's perfectly valid data, with three data entries.  QBASIC doesn't require DATA to be inside quotes, so the "Hello World" is one string, the comma is the delimiter, "Steve is Awesome" is a second string, the comma is the delimiter, "Steve's the best!" is the third string.


DATA considers ' to be a perfectly valid part of your data.   It doesn't know "7  ' this is a comment" is a comment and only 7 is data.  How could it tell that apart from "6' 3" tall"?

Add the colon in there, and it'll run properly for you, with no issues.
Reply


Messages In This Thread
RE: I have learned something new: how to get a run-time syntax error - by SMcNeill - 09-25-2024, 04:36 PM



Users browsing this thread: 1 Guest(s)