PC-BASIC

BASIC, one of the oldest programming languages, helped make home computers popular in the 1980s. You can run the old GW-BASIC programs from the DOS era in PC-BASIC, a modern emulator.

The BASIC programming language was invented in 1964, and Bill Gates wrote a BASIC interpreter for the Altair 8800 computer in 1975, one of the first Microsoft products. One of its successors is GW-BASIC, the default BASIC version that came with early MS-DOS versions.

After 60+ years, it’s astonishing that BASIC is still around. In fact, the BASIC dialect Visual Basic for Applications (VBA) is the macro language for Microsoft’s current Office programs (Word, Excel, PowerPoint, and Outlook).

In this article, I look at PC-BASIC, a highly compatible GW-BASIC emulator that is available for Windows, Linux, macOS, and any system that runs Python 3.6 or later. For the full retro experience, you can also run GW-BASIC in DOSBox.

First Steps

You can download an MSI file for Windows, a DMG archive for macOS, or DEB and RPM packages for various Linux distributions to get PC-BASIC running. If none of these options work, you can try the Python package pcbasic, which will install with pip on any modern machine that’s supported by Python.

I’ll get started with some basic (pun intended) BASIC commands: PC-BASIC is a classic BASIC dialect and needs line numbers on each line to arrange the collection of program lines. Enter

10 PRINT "Maker Space ";
20 GOTO 10
RUN

and you’ve taken the first step that so many children of the 1980s took in a local electronics store where home computers were on display (and plugged in): The text scrolls across the screen. Press Ctrl+C to stop it, and BASIC will say

Break in 10
Ok

The PRINT command prints text on the screen; the semicolon prevents the interpreter from adding a line break. With GOTO, you jump back to line 10. A prettier version that shows off the available colors is COLDEMO.BAS (Listing 1); Figure 1 shows its output. The COLOR command sets the foreground and background colors for text that you’ll PRINT. If you give it a third argument (as in line 10 of Listing 1), you can set the screen border color.

b01_coldemo.tif
Figure 1: Thanks to the COLOR command, you can print in various background and foreground colors.

Listing 1: COLDEMO.BAS

10 SCREEN 0 : COLOR 15,4,13
15 WIDTH 80 : CLS
20 FOR BG = 0 TO 7    ' Background
30   FOR FG = 0 TO 15 ' Foreground
40     COLOR FG,BG
50     PRINT "Maker Space! ";
60   NEXT FG
70 NEXT BG
80 COLOR 15,4

WIDTH sets the number of characters per line (either 80 or 40), CLS clears the screen, and lines 20 and 30 start outer and inner FOR loops that let variables cycle through some of the valid color values. Try an illegal color code and you’ll be told

COLOR 3,99
Illegal function call
Ok

If you’re happy with your program’s performance, you can save it to disk so that you can keep it forever. I have several boxes of floppy disks with the programs I wrote in my youth – but please don’t ask me whether I could quickly read those oddly-formatted 3- and 5.25-inch disks. (And no, 3-inch is not a typo; the Amstrad home computers used 3-inch disks, not the more popular 3.5-inch ones.) Then, use the SAVE command

SAVE "SUPERPRG"

PC-BASIC will automatically add a .BAS file extension. If you use more than eight characters, the name will be shortened to meet DOS file name standards. Note that PC-BASIC will store the program in a binary format. It’s not compressed, so you’ll still see variable names and comments (Figure 2), but line numbers and commands are stored as tokens. If you want to save your program in a readable (ASCII) format, add ,A to the command as follows:

SAVE "SUPERPRG",A
b02_hexdump.tif
Figure 2: The binary format contains readable comments and variable names.

After restarting PC-BASIC, you can load a stored program with the LOAD command. PC-BASIC expects a file name (with or without the .BAS extension), and it will load both binary and ASCII versions. Because of its compatibility with GW-BASIC, PC-BASIC also will load binary files that were created by GW-BASIC.

Graphics

As a final example, I’ll do some wild graphics. Calculating coordinates on a circle requires trigonometric functions, and PC-BASIC supports SIN, COS, and a few others. The LINE command

LINE (AX, AY)-(BX, BY), COL

(used in line 280 of Listing 2) will draw a line between the coordinates (AX, AY) and (BX, BY) in color COL. You can watch the creation and destruction of the circle, which goes on forever thanks to the GOTO command in line 300 (Figure 3).

GW-BASIC in DOSBox

Listing 2: CIRCLE.BAS

100 ' PC‑BASIC/GW‑BASIC Graphics Demo
110 ' (c) 2025 Hans‑Georg Esser
120 SCREEN 2 : WIDTH 40 : COLOR 1,2 : ' PALETTE 0,1
130 LOCATE 12,18:PRINT "MAKER"
140 LOCATE 13,18:PRINT "SPACE"
150 RAD1 = 100 : RAD2 = 50
160 CX = 160 : CY = 100 ' Center point
170 PI = 3.141593
180 ANGLE = 0
190 STP = PI / 45
200 ' Main loop
210 WHILE ANGLE < 4*PI:
220   ANGLE = ANGLE + STP
230   IF ANGLE < 2*PI THEN COL = 1+INT(3*RND(100)) ELSE COL = 0
240   AX = CX + RAD1 * COS(ANGLE)
250   AY = CY + RAD1 * SIN(ANGLE)
260   BX = CX + RAD2 * COS(ANGLE+PI*.6)
270   BY = CY + RAD2 * SIN(ANGLE+PI*.6)
280   LINE (AX, AY)‑(BX, BY), COL
290 WEND
300 GOTO 180
b03_circle.tif
Figure 3: You’ve earned it: After typing in all those lines, PC-BASIC rewards you with a colorful animation.

If you prefer Microsoft’s original GW-BASIC interpreter, you can download it. Choose the *.zip archive for version 3.23 and unpack it to reveal gwbasic.exe, which will run perfectly in DOSBox. If you go this route, you might also prefer the original reference documentation over the PC-BASIC manuals.

During testing, I found that one major advantage of the new implementation is that PC-BASIC lets you copy and paste: Use the mouse to select any text in the BASIC window to move it to the clipboard and then insert the clipboard content by pressing the middle mouse button. DOSBox can also perform copy and paste, but not as easily as PC-BASIC. Whichever BASIC version you decide to play with, happy hacking!