From Infogalactic: the planetary knowledge core
Jump to: navigation, search
Developer Microsoft
First appeared 1983; 35 years ago (1983)
Stable release 3.23 / 1988; 30 years ago (1988)
Website {{#property:P856}}
Influenced by
QBasic, QuickBasic, MSX BASIC

GW-BASIC is a dialect of the BASIC programming language developed by Microsoft from BASICA, originally for Compaq. It is otherwise identical to Microsoft/IBM BASICA, but is a fully self-contained executable and does not need the ROM BASIC. It was bundled with MS-DOS operating systems on IBM PC compatibles by Microsoft. Microsoft also sold a BASIC compiler, BASCOM, compatible with GW-BASIC, for programs needing more speed. The language is suitable for simple games, business programs and the like. Since it was included with most versions of MS-DOS, it was also a low cost way for many would-be programmers to learn the fundamentals of computer programming.[1][2] With the release of MS-DOS 5.0, GW-BASIC's place was eventually taken by QBasic, the interpreter part of the separately available QuickBASIC compiler.[3]


IBM BASICA and GW-BASIC are direct ports of Microsoft's BASIC-80 (also known as MBASIC) designed for 8080/Z80 machines, but added features specifically for the IBM PC hardware. Common features of BASIC-80 and BASICA/GW-BASIC include:

  • CLS command to clear the screen
  • Double-precision variables
  • True integer support
  • PRINT USING statement for formatted display output
  • LPRINT for outputting to printers
  • WHILE...WEND loops
  • The ability to save programs in three formats (ordinary tokenized binary, ASCII, or a "protected" token format that cannot be LISTed)
  • "Ok" as the BASIC prompt
  • DEFINT statement to set all variables beginning with the specified characters as one type, eliminating the need to put type suffixes after them
  • INKEY$ function to read key presses
  • An advanced editor which included statements for renumbering program lines and deleting them in blocks
  • Hexadecimal number support (performed by preceding numbers with &H)
  • The REM statement can be abbreviated as '
  • Statements that have quoted text (e.g. PRINT) do not require a second quote mark at the end unless other arguments follow
  • IN/OUT instructions for I/O
  • Error trapping features

Conversely, BASIC-80/BASICA/GW-BASIC does not allow the line crunching in 6502 versions (where no spaces are required on a program line).

MBASIC programs not using PEEK/POKE statements would run under GW-BASIC. BASICA added a large number of features for the IBM PC such as sound, graphics, and memory commands.

Microsoft did not offer a generic version of MS-DOS until v3.20 in 1986 and before then, all variants of the OS were OEM ones. Depending on the OEM, BASIC was distributed as either BASICA.EXE or GWBASIC.EXE. The former should not be confused with IBM BASICA, which always came as a .COM file. Some variants of BASIC had extra features to support a particular machine (for example, the AT&T and Tandy versions of DOS included a special GW-BASIC that supported their enhanced sound and graphics capabilities).

The initial version of GW-BASIC was the one included with Compaq DOS 1.13 (released with the Compaq Portable in 1983) and was analogous to IBM BASICA 1.10. It used the CP/M-derived file control blocks for disk access and did not support subdirectories. Later versions added this feature and improved graphics and other capabilities.

GW-BASIC 3.20 (1986) added EGA graphics support (no version of BASICA or GW-BASIC had VGA support) and was in effect the last new version released before it was superseded by QBasic.

Buyers of Hercules Graphics Cards received a special version of GW-BASIC on the card's utility disk that was called HBASIC and which added support for its 720×348 monochrome graphics (other versions of BASICA/GW-BASIC only allowed graphics on Hercules cards if SIMCGA was loaded).

GW-BASIC has a command line-based integrated development environment (IDE) based on Dartmouth BASIC. Using the cursor movement keys, any line displayed on screen can be edited. It also includes function key shortcuts at the bottom of the screen. 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, because it was an interpreted programming language. All program lines must be numbered; all non-numbered lines are considered to be commands in direct mode to be executed immediately. Program source files are normally saved in binary compressed format with tokens replacing commands, with an option to save in ASCII text form.[4]

The GW-BASIC command-line environment has commands to RUN, LOAD, SAVE, LIST the current program, or quit to the operating SYSTEM; these commands can also be used as program statements. There is little support for structured programming in GW-BASIC. 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)). The data type of variables can be specified with a character at the end of the variable name: A$ is a string of characters, A% is an integer, etc. Groups of 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.[5]

GW-BASIC allowed use of joystick and light pen input devices. GW-BASIC can read from and write to files and COM ports; it can also do event trapping for ports. Since the cassette port interface of the original IBM PC was never implemented on compatibles, cassette operations are not supported. GW-BASIC can play simple music using the PLAY statement, needing a string of notes represented in a music macro language (e.g. PLAY "edcdeeL2edfedL4c"). 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 three channels of sound for the SOUND and PLAY commands.[5]


There are several theories on what the initials "GW" stand for. Greg Whitten, an early Microsoft employee who developed the standards in the company's BASIC compiler line, says Bill Gates picked the name GW-BASIC. Whitten refers to it as Gee-Whiz BASIC and is unsure if Gates named the program after him.[6] The Microsoft User Manual from Microsoft Press also refers to it by this name.[citation needed] It may have also been nicknamed Gee-Whiz because it had a large number of graphics commands.[6] Other common theories as to the initials' origins include "Graphics and Windows", "Gates, William" (Microsoft's president at the time), or "Gates-Whitten" (the two main designers of the program).[7][8]


  1. "KindlyRat". "GW-BASIC". Archived from the original on 2005-07-26. Retrieved 2009-11-10.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  2. "Leon". "GWBASIC Games & Other Programs". Archived from the original on 2009-10-26. Retrieved 2009-11-10.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  3. "Microsoft BASIC version information". Retrieved 2008-06-12.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  4. "GW-BASIC Documentation and Utilities". Archived from the original on 2007-12-17.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  5. 5.0 5.1 "GW-BASIC User's Guide". 1987. Retrieved 2008-06-28.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  6. 6.0 6.1 Gregory Whitten (2005-04-13). "GW-BASIC". Retrieved 2008-06-29.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  7. "Linux Dictionary:G". Retrieved 2008-06-28.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>
  8. "GW-BASIC". 2005-04-13. Retrieved 2008-06-28.<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>

External links