GW-BASIC

From Wikipedia, the free encyclopedia

GW-BASIC 3.22 displaying the Hello world program
Enlarge
GW-BASIC 3.22 displaying the Hello world program

GW-BASIC was a dialect of BASIC developed by Microsoft from BASICA, originally for Compaq.

It is compatible with Microsoft/IBM BASICA, but was disk based and did not require the resources of the ROM included on IBM's machines. It was bundled with MS-DOS operating systems on IBM PC compatibles by Microsoft. Like other early microcomputer versions of BASIC, GW-BASIC lacked many of the structures needed for structured programming such as local variables, and GW-BASIC programs executed relatively slowly, due to the fact that it was an interpreted programming language. It did have a large number of graphics commands.

Still, it had enough flexibility to allow one to write simple games, business programs and the like. Since it was available on any PC, it was also a cheap way for would-be programmers to learn the rudiments of computer programming. It also provided a way to develop impressive science fair projects for aspiring students willing to deal with the frustrations of programming in such a spartan system.

GW-BASIC has a command line-based Integrated Development Environment (IDE) system based on the original introduced at Dartmouth College; all program lines must be numbered, all non-numbered lines are considered to be commands in direct mode (ie, to be executed immediately). The user interface is almost completely command line, except for the function key shortcuts at the bottom and an initial copyright notice at the top of the screen. Files are normally saved in a GW-BASIC binary compressed format with tokens replacing commands; however, it has an option to save programs in ASCII text form.

The GW-BASIC IDE has commands to RUN,LOAD,SAVE,LIST the current program, or quit to the operating SYSTEM. Although they may all be used as program statements such use is rare for all commands except SYSTEM.

There is little support for structured programming in GW-BASIC and therefore it is very much up to GW-BASIC programmers, themselves, to provide a good structure for their programs. All IF/THEN/ELSE conditional statements must be written on one line, although WHILE/WEND statements may group multiple lines. Functions can only be defined using the single line DEF FNf(x)=<mathematical function of x> statement (e.g., DEF FNLOG(base,number)=LOG(number)/LOG(base)). Variables are often typed via a type symbol at the end of their name: A$ is a string, A% is an integer, etc. Groups of undeclared variables can also be set to default types based on the initial letter of their name by use of the DEFINT, DEFSTR, etc., statements. The default type for undeclared variables not identified by such typing statements, is single-precision floating-point.

Because many GW-BASIC programmers were without formal training, they often failed to see the need for simple structuring and as a result made extensive, undisciplined use of GOTOs rather than using them as replacements for the missing structural statements. See spaghetti code.

GW-BASIC allowed for the joysticks and pen-input devices of its time, but not for mice. (It is possible to use pen-input commands for mice, but the reliability of the mouse responding properly to pen requests is poor.) GW-BASIC can read from and write to files, LPT ports, and COM ports; it can also do event trapping for ports. It cannot handle tape devices. It is able to play simple sheet music using the PLAY statement, requiring a string of notes (e.g. PLAY "edcdeee2dfedc4"). More low-level control is possible with the SOUND statement, which takes the arguments of a frequency in hertz and a length in clock ticks for the standard internal PC speaker in IBM machines. Consequently sound is limited to single channel beeps and whistles as befits a 'business' machine. Home based PCs such as the Tandy 1000, allowed up to 3 channels of sound for the SOUND and PLAY commands. GW-BASIC also implemented a NOISE command which had 8 sound effects that could be pitch, speed, and length altered.

GW-BASIC's place in the MS-DOS distribution was eventually taken by Microsoft QBASIC, a cut-down version of the separately available Microsoft QuickBASIC compiler. GW-BASIC's main advantage over BASICA was that it did not require a BASIC interpreter on the ROM and so could be used on non-IBM PCs.

The initials "GW" may have been named after Greg Whitten, an early Microsoft employee who developed the standards in the Microsoft basic compiler line. It is also purported to stand for gee-whiz. Greg Whitten is not certain on this matter. [1] An alternative theory is that "GW" stands for "Gates, William". [2] Another common expansion is "Graphics and Windows", as neither feature was supported by BASICA.

The MS User Manual from MS Press for GWBASIC states that GW stands for Gee Whiz.

[edit] See also

[edit] External links