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:
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:
Fixed-Length StringsA regular integer variable can store any whole number from -32768 through
- Use "%" to declare regular integers.
Example: integer% = 10
DIM strName AS STRING * n
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:
"ON ERROR GOSUB.../ON KEY(n) GOTO..."
PRINT "You had an error!"
PRINT "Error" ERR
ON ERROR GOTO errhandler
FUNCTION name [parameterlist][STATIC]
name = expression
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.
Artikel-id: 73084 - Laatst bijgewerkt: 12 mei 2003 - Revisie: 1