10-02-2024, 07:04 PM
(09-25-2024, 04:36 PM)SMcNeill Wrote: The issue you're seeing is that you're trying to read a string as a number, and that's the run-time error."'I see,' said the blind man, as he picked up his hammer and saw."
For example:
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.Code: (Select All)DATA Hello World, Steve is Awesome, Steve's the best!
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.
A data statement only needs quotes if you're going to have anything not part of that string following it, or you want to keep leading and/or trailing blanks. Like this:
Code: (Select All)
Read A, A$
Print A; A$
Read A, A$
Print A; A$
Read A, A$
Print A; A$
Read A, A$
Print A; A$
End
Data 6,A string
Data 6,"A string"
Data 6," A string"
Data 6,A string 'And more of the same
The third one is the only one that had leading blanks, and the 4th one took everything after the comma as the datum.Nothing like writing a program and submitting it to the compiler for its final, infallible opinion.
To paraphrase a saying a Supreme Court justice used to describe the organization,
"The compiler's opinion is not final because it is infallible, it is infallible because it is (unless you want to rewrite parts of the compiler) final."
While 1
Fix Bugs
report all bugs fixed
receive bug report
end while
Fix Bugs
report all bugs fixed
receive bug report
end while