Differences Between GW-BASIC and QBasic
This article was previously published under Q73084
This article has been archived. It is offered "as is" and will no longer be updated.
This article lists the improvements in QBasic over GW-BASIC and someof the major differences between the two.
QBasic is a subset of QuickBasic version 4.5. The QBasic online helpfeature contains complete articles explaining version differences betweenBASICA/GW-BASIC and QBasic, unsupported keywords, and converting BASICAprograms for use under QBasic.
QBasic provides a "Windows-like" environment supporting the use of a mouse.A menu bar across the top of the screen contains pull-down menu selections.
QBasic provides a split screen. The upper portion of the screen is calledthe view window and is for program code; at the bottom of the screen, an"immediate" window allows testing of a programming instruction prior toincluding it in a program.
With QBasic, you don't need to use line numbers. However, line numbers aresupported. Also, QBasic now supports line "labels." These labels are notrequired on every line, however, but can be used to direct program flow. Asa result, QBasic has no RENUM command such as that of GW-BASIC. Forexample:
Line label "Bob:" or line number "10" are both valid.QBasic includes friendly, extensive online help. For more information aboutusing QBasic, press ENTER immediately after starting QBasic or press F1 anytime while running QBasic. If you are using a mouse, point to the Help menuoption on the right side of the menu bar (on the top right of the displayedscreen).
You can cut and paste examples of program code from the online help screenand place them directly into the view window for execution.
QBasic uses IEEE floating point math, the industry standard. GW-BASIC usesthe MBF math format. For more information on IEEE vs. Microsoft BinaryFormat, query on the following words:
Tutorial and IEEE and MBFQBasic is a subset of QuickBasic 4.5. QuickBasic 4.0 and later willsupport a math co-processor, however, QBasic does not.
QBasic uses P-code, which stands for "pseudo code," so called because it'svery similar to compiled code, but it's not completely compiled. P-coderetains just enough information -- the crucial last bits that real machinecode loses -- for listing it on the screen in source code format and forany modifications you decide to make. Yet, because it looks almost like theoutput of a compiler, it runs almost as fast as you would expect anexecutable file to run. Consequently, you get all the advantages of usingan interpreter with virtually no speed penalty and little size penalty.
QBasic supports additional variable types: User-Defined Types, Fixed-LengthStrings, and Long Integers.
Use the type If the variable is: declaration character: ------------------- ---------------------- String $ Integer Regular % Long & Floating Point Single-precision ! Double-precision #
Fixed-Length StringsA regular integer variable can store any whole number from -32768 through
- Use "%" to declare regular integers.
Example: integer% = 10
where strName is the name of the fixed-length string and n is the stringlength.
DIM strName AS STRING * n
Long IntegersA long integer variable can represent a whole number from -2,147,483,648through 2,147,483,647. Use "&" to declare long integers.
Example: employees& = 15000000Single-precision floating-point variables can represent a number up toseven digits in length. The decimal point can be anywhere within thosedigits. Use "!" to declare single-precision floating-point variables.
Example: speed!= 33.33333Double-precision floating-point variables can represent a number up to15 digits in length. The decimal point can be anywhere within thosedigits. Use "#" to declare double-precision floating point variables.
Example: pi# = 3.141592654QBasic allows 64K memory for code per subroutine and 64K for data. Arrays,fixed-length strings, and user-defined types get 64K each. There is 64K ofmemory available for CODE per SUBroutine and 64K of memory for DATA. Youcan also have far arrays of numerics, fixed-length strings, and user-defined types of up to 64K each.
QBasic allows error/event trapping:
QBasic allows variable/value parameter passing. SUB/END SUB and UNCTION/ENDFUNCTION. QBasic provides a way to share arguments with a limited number ofsubprograms rather than with the entire program. This method is calledpassing arguments.
"ON ERROR GOSUB.../ON KEY(n) GOTO..." Example: CALL mysub END errhandler: PRINT "You had an error!" PRINT "Error" ERR RESUME NEXT SUB mysub ON ERROR GOTO errhandler ERROR 62 END SUB
Syntax: SUB globalname[parameterlist][STATIC] [statements] [EXIT SUB] [statements] FUNCTION name [parameterlist][STATIC] [statements] name = expression [statements] END FUNCTION END SUB
File Conversion from GW-BASIC to QBasicTo use a GW-BASIC program in QBasic, you must first save the file in anASCII text format.
Example: SAVE: "PROGNAME.BAS",A.
Converting a GW-BASIC Program to QBasicUse REMLINE.BAS included with MS-DOS for QBasic to remove line numbers fromGW-BASIC programs. For more information, see the documentation provided atthe beginning of REMLINE.BAS by opening the file in QBasic.
To load GW-BASIC programs to QBasic, you must use the command "QBasic/MBF" when starting QBasic from the DOS prompt.
6.22 5.00 5.00a 6.00 6.20 6.21
Article ID: 73084 - Last Review: 12/04/2015 09:08:36 - Revision: 2.0
Microsoft MS-DOS 5.0 Standard Edition, Microsoft MS-DOS 5.0a, Microsoft MS-DOS 6.0 Standard Edition, Microsoft MS-DOS 6.2 Standard Edition, Microsoft MS-DOS 6.21 Standard Edition, Microsoft MS-DOS 6.22 Standard Edition
- kbnosurvey kbarchive KB73084