![]() | |
Developer | Microsoft |
---|---|
First appeared | 1983; 42 years ago (1983) |
Stable release | 3.23 / 1988; 37 years ago (1988) |
OS | DOS |
License | Proprietary MIT License (v1.0)[1] |
Influenced by | |
IBM Cassette BASIC,IBM Disk BASIC,IBM BASICA | |
Influenced | |
QBasic,QuickBasic,MSX BASIC |
GW-BASIC is a dialect of theBASICprogramming language developed byMicrosoft fromIBM BASICA. Functionally identical to BASICA, itsBASIC interpreter is a fully self-contained executable and does not need theCassette BASIC ROM found in the original. It was bundled withMS-DOSoperating systems onIBM PC–compatibles by Microsoft.
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 aspiringprogrammers to learn the fundamentals ofcomputer programming.[2][3] Microsoft also sold a BASICcompiler, BASCOM, compatible with GW-BASIC, for programs needing more speed.
According to Mark Jones Lorenzo, given the scope of the language, "GW-BASIC is arguably thene plus ultra of Microsoft's family of line-numbered BASICs stretching back toAltair BASIC — and perhaps even of line-numbered BASIC in general."[4]
With the release of MS-DOS 5.0, GW-BASIC's place was taken byQBasic, a slightly abridged version of the interpreter part of the separately availableQuickBASIC interpreter and compiler package.[5]
On May 21, 2020, Microsoft released the8088 assembler source code for GW-BASIC 1.0 onGitHub under theMIT License.[1]
IBM BASICA and GW-BASIC are largely ports ofMBASIC version 5.x, but with added features specifically for the IBM PC hardware. Common features of BASIC-80 5.x and BASICA/GW-BASIC include:
WHILE...WEND
loopsOPTION BASE
statement to set the starting index of array variables as either 0 or 1LINE INPUT
, which allowed field-separator characters like comma to be ignoredCALL
statement for executing machine-language routinesCHAIN
andMERGE
commandsThe ability to "crunch" program lines by omitting spaces, a common feature of earlier Microsoft BASIC implementations, was removed from BASIC-80 5.x and BASICA/GWBASIC.
BASIC-80 programs not usingPEEK
/POKE
statements run under GW-BASIC. BASICA adds many features for the IBM PC such as sound, graphics, and memory commands. Features not present in BASIC-80 include the ability to execute theRND
function with no parameters and the ability to also save programs in a "protected" format, preventing them from beingLIST
ed. BASICA also allows double-precision numbers to be used with mathematical and trigonometric functions such asCOS
,SIN
, andATN
, which wasn't allowed in 8-bit versions of BASIC. This feature was normally not enabled and required the optional parameter/D
at startup, i.e.,GWBASIC /D
. BASIC'smemory footprint was slightly increased if it was used.
Microsoft did not offer a generic version of MS-DOS until v3.20 in 1986; before then, all variants of the operating system were OEM versions. 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 aCOM file. Some variants of BASIC has extra features to support a particular machine. For example, the AT&T and Tandy versions of DOS include a special GW-BASIC that supports their enhanced sound and graphics capabilities.
The initial version of GW-BASIC is the one included with Compaq DOS 1.13, released with theCompaq Portable in 1983, and was analogous to IBM BASICA 1.10. It uses theCP/M-derived file control blocks for disk access and does not support subdirectories. Later versions support subdirectories, improved graphics, and other capabilities.
GW-BASIC 3.20 (1986) addsEGA graphics support (no version of BASICA or GW-BASIC hadVGA support) and is the last major new version released before it was superseded byQBasic.
Buyers ofHercules Graphics Cards received a special version of GW-BASIC on the card's utility disk that is called HBASIC, which adds support for its 720×348 monochrome graphics. Other versions of BASICA/GW-BASIC do not support Hercules graphics and can only display graphics on that card through the use of third-partyCGA emulation, such as SIMCGA.
GW-BASIC has acommand-line-basedintegrated development environment (IDE) based onDartmouth BASIC. Using the cursor movement keys, any line displayed on the screen can be edited. It also includesfunction key shortcuts at the bottom of the screen. Like other earlymicrocomputer versions of BASIC, GW-BASIC lacks many of the structures needed forstructured programming, such as local variables. GW-BASIC programs executed relatively slowly because it was aninterpreted language. All program lines must be numbered; all non-numbered lines are considered to be commands indirect mode to be executed immediately. Program source files are normally saved in binary compressed format withtokens replacing keywords, with an option to save inASCII text form.[6]
The GW-BASIC command-line environment has commands toRUN
,LOAD
,SAVE
,LIST
the current program, or quit to the operatingSYSTEM
; these commands can also be used as program statements. There is little support forstructured programming in GW-BASIC. AllIF
/THEN
/ELSE
conditional statements must be written on one line, althoughWHILE
/WEND
statements may group multiple lines.Functions can only be defined using the single lineDEF FNf(x)=<mathematical function of x>
statement (e.g.,DEF FNLOG(base,number)=LOG(number)/LOG(base)
). The data type ofvariables can be specified with a character at the end of the variable name:A$
is astring of characters,A%
is aninteger, etc. Groups of variables can also be set to default types based on the initial letter of their name by use of theDEFINT
,DEFSTR
, etc., statements. The default type for undeclared variables not identified by such typing statements is single-precisionfloating-point (32-bit MBF).[7]
GW-BASIC allows use ofjoystick andlight pen input devices. GW-BASIC can read from and write to files andCOM ports; it can also do event trapping for ports. Since the cassette tape port interface of the original IBM PC was never implemented on compatibles, cassette operations are not supported. GW-BASIC can play simple music using thePLAY
statement, needing a string of notes represented in amusic macro language, e.g.,PLAY "edcdeeL2edfedL4c"
. Morelow-level control is possible with theSOUND
statement, which takes the arguments of afrequency inhertz and a length in clock ticks for the standard internalPC speaker in IBM machines. Consequently, sound is limited to single channel beeps and whistles as befits a "business" machine. GW-BASIC for theTandy 1000 allows up to three channels of sound for theSOUND
andPLAY
commands.[7]
There are several theories on what the initials "GW" represent.Greg Whitten, an earlyMicrosoft employee who developed the standards in the company's BASIC compiler line, says thatBill Gates picked the name GW-BASIC. Whitten refers to it asGee-Whiz BASIC and is unsure whether Gates named the program after him.[8] TheMicrosoft User Manual fromMicrosoft Press also refers to it by theGee-Whiz BASIC name.[citation needed] It may have also beennicknamedGee-Whiz because of its numerousgraphics commands.[8] 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).[9][10]