Article ID: 73084 - View products that this article applies to.
This article was previously published under Q73084
This article lists the improvements in QBasic over GW-BASIC and some of the major differences between the two.
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.
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 called the view window and is for program code; at the bottom of the screen, an "immediate" window allows testing of a programming instruction prior to including it in a program.
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:
QBasic includes friendly, extensive online help. For more information about using QBasic, press ENTER immediately after starting QBasic or press F1 any time while running QBasic. If you are using a mouse, point to the Help menu option on the right side of the menu bar (on the top right of the displayed screen).
Line label "Bob:" or line number "10" are both valid.
You can cut and paste examples of program code from the online help screen and place them directly into the view window for execution.
QBasic uses IEEE floating point math, the industry standard. GW-BASIC uses the MBF math format. For more information on IEEE vs. Microsoft Binary Format, query on the following words:
Tutorial and IEEE and MBFQBasic is a subset of QuickBasic 4.5. QuickBasic 4.0 and later will support a math co-processor, however, QBasic does not.
QBasic uses P-code, which stands for "pseudo code," so called because it's very similar to compiled code, but it's not completely compiled. P-code retains just enough information -- the crucial last bits that real machine code loses -- for listing it on the screen in source code format and for any modifications you decide to make. Yet, because it looks almost like the output of a compiler, it runs almost as fast as you would expect an executable file to run. Consequently, you get all the advantages of using an interpreter with virtually no speed penalty and little size penalty.
QBasic supports additional variable types: User-Defined Types, Fixed-Length Strings, 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
where strName is the name of the fixed-length string and n is the string length.
Long IntegersA long integer variable can represent a whole number from -2,147,483,648 through 2,147,483,647. Use "&" to declare long integers.
Single-precision floating-point variables can represent a number up to seven digits in length. The decimal point can be anywhere within those digits. Use "!" to declare single-precision floating-point variables.
Example: employees& = 15000000
Double-precision floating-point variables can represent a number up to 15 digits in length. The decimal point can be anywhere within those digits. Use "#" to declare double-precision floating point variables.
Example: speed!= 33.33333
QBasic 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 of memory available for CODE per SUBroutine and 64K of memory for DATA. You can also have far arrays of numerics, fixed-length strings, and user- defined types of up to 64K each.
Example: pi# = 3.141592654
QBasic allows error/event trapping:
QBasic allows variable/value parameter passing. SUB/END SUB and UNCTION/END FUNCTION. QBasic provides a way to share arguments with a limited number of subprograms rather than with the entire program. This method is called passing arguments.
File Conversion from GW-BASIC to QBasicTo use a GW-BASIC program in QBasic, you must first save the file in an ASCII 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 from GW-BASIC programs. For more information, see the documentation provided at the 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.
Article ID: 73084 - Last Review: May 12, 2003 - Revision: 2.0
Contact us for more help
Connect with Answer Desk for expert help.