INPUT [[<string-expression>] {,|;}] <variable>[,<variable> ...][;]QBasic (and GW-Basic, etc.) supports an optional prompt string, but it must be a string constant. TrueBASIC (ANSI BASIC) allows a string expression but it is preceded by the PROMPT keyword (followed by a colon and the "? " is suppressed). ANSI BASIC has some other options in additional to PROMPT (perhaps TrueBASIC does now too, but not in the 1985 version).
A string expression will be used for the prompt so that anything can be used for the prompt, not just a string constant (which is too restrictive). Similar to QBasic, a comma separator after the prompt outputs just the value of the string expression, and a semicolon will add "? " after the prompt. If there is no string expression or separator, then the standard "? " is output. The prompt is optional, and if there is just a separator, then there will just the "? " (semicolon) or no prompt (comma). Using just the semicolon is pointless because it is the same as not having the semicolon. Using just the comma will have no prompt (which gives errors with both QBasic and GW-Basic).
The trailing optional semicolon will keep the cursor on the same line after the input is entered. QBasic (and the others) accomplish this with the optional semicolon directly after the INPUT keyword. This is weird and it makes more sense to put the optional semicolon at the end just like with the PRINT statement.
Note: Debugging will resume on the error reporting issues, but I have little time available during this week and wanted to get started with the background for the INPUT command.
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)