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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Today I learned loops are slow CMR 10 985 12-20-2025, 02:15 PM
Last Post: TDarcos
  Pointlessly Walk or Run forever! (update 0002) Cobalt 14 2,757 01-24-2025, 07:04 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)