Closed kimpro82 closed 1 year ago
Q73084: Differences Between GW-BASIC and QBasic
QBasic is a subset of QuickBasic version 4.5. The QBasic online help feature
contains complete articles explaining version differences between
BASICA/GW-BASIC and QBasic, unsupported keywords, and converting BASICA programs
for use under QBasic.
……
With QBasic, you don't need to use line numbers. However, line numbers are
supported. Also, QBasic now supports line "labels." These labels are not
required on every line, however, but can be used to direct program flow. As a
result, QBasic has no RENUM command such as that of GW-BASIC. For example:
Line label "Bob:" or line number "10" are both valid.
All BASIC program lines have the following syntax:
[line-identifier][statement][:statement]...[comment]
Line identifier
A line in BASIC may have one line-identifier. BASIC supports two types of
line-identifiers (which may be used in the same program):
- line numbers
- Range 0 to 65,529
- May begin in any column; must be first character in the line
- line numbers (examples):
200
300 PRINT"hello" '300 is the line number
- line numbers (special notes):
- Using 0 is not recommended since it has a special meaning to
the ON ERROR, ON event, and RESUME statements.
- Line numbers do not determine the order in which statements
are executed in QuickBASIC. For example, QuickBASIC executes
statements in the following program in the order 100, 10, 5:
100 PRINT "The first line executed."
10 PRINT "The second line executed."
5 PRINT "The third and final line executed."
Some older BASICs, such as BASICA, would expect the lines
to be in numerical order: 5, 10, 100.
- alphanumeric line labels
- 1 to 40 letters and digits.
- Must start with a letter and end with a colon.
- BASIC keywords are not permitted.
- May begin in any column; must be first character in the line.
- Case is not significant (alpha:, AlPHa: and ALPHA: are equivalent
line labels).
- Blanks and tabs are allowed between the label and the colon.
- alphanumeric line labels (examples):
Alpha:
ScreenSub:
- alphanumeric line labels (special notes):
- May not be used in IF...THEN statements, unless you use a
GOTO statement:
IF A = 10 THEN 500 'correct use of line number
- If the object of the IF...THEN statement is a line label, a
GOTO statement is required:
IF A = 10 THEN GOTO IncomeData
BASIC Line Length
- From within the QuickBASIC editor
- QuickBASIC's built-in editor limits the length to 256 characters
- The underscore character (_) cannot be used for line continuation
- From within your own editor
- You may use the underscore as the last character to create a program
line, like the following, that extends across more than one physical
line:
IF (TestChar$ = " " OR TestChar$ = ".") AND LineNumber < 23 _
AND NOT EOF(FileNumber) THEN
- When QuickBASIC loads your program, the underscores are removed and
the continued lines are joined to form a single line that may
exceed 256 characters in length
- Underscores cannot be used to continue DATA or REM statements
Nostalgia