A GW-BASIC / QBasic interpreter written in C#. Runs classic BASIC programs in the console or browser.
Try it online — no installation required!
- GW-BASIC Compatibility: Supports most GW-BASIC commands and functions
- QBasic Extensions: SUB/FUNCTION procedures, SELECT CASE, DO/LOOP, CONST
- Graphics: Full support for SCREEN modes, LINE, CIRCLE, PSET, PAINT, etc.
- Sound: BEEP, SOUND, and PLAY commands
- File I/O: OPEN, CLOSE, INPUT#, PRINT#, LINE INPUT#
- Cross-Platform Core: Interpreter core runs on any .NET platform
- Two Interfaces:
- Windows console with graphics overlay
- WebAssembly browser version (Blazor)
Pre-built binaries are available in the bin/ folder:
basic.exe— Windows console application (self-contained, no .NET required)basic-web.zip— Browser version (extract and openindex.html)
# Clone the repository
git clone https://github.com/user/Basic.git
cd Basic
# Run the interpreter
dotnet run --project Basic.Cli
# Run a specific program
dotnet run --project Basic.Cli -- samples/mandelbrot.bas
# Run with separate graphics window
dotnet run --project Basic.Cli -- --window samples/plasma.basSharpBasic 1.0
60300 Bytes free
Ok
PRINT "Hello, World!"
Hello, World!
Ok
# Run a program file
basic samples/cube3d.bas
# Run with graphics window mode
basic --window samples/fire.bas
basic -w samples/plasma.bas
# Console overlay mode (default)
basic --console samples/starfield.bas
basic -c samples/mandelbrot.bas| Command | Description |
|---|---|
RUN |
Execute the current program |
LIST |
Display program listing |
LOAD "file.bas" |
Load a program from file |
SAVE "file.bas" |
Save program to file |
NEW |
Clear program from memory |
CLS |
Clear screen |
FILES |
List files in current directory |
The samples/ directory contains various demonstration programs:
| Program | Description |
|---|---|
mandelbrot.bas |
Mandelbrot fractal visualization |
plasma.bas |
Real-time plasma effect |
fire.bas |
Fire simulation |
cube3d.bas |
Rotating 3D wireframe cube |
starfield.bas |
3D starfield animation |
fern.bas |
Barnsley fern fractal |
sierpinski.bas |
Sierpinski triangle |
gorilla.bas |
Classic QBasic game |
life.bas |
Conway's Game of Life |
tunnel.bas |
3D tunnel effect |
GOTO, GOSUB, RETURN, IF...THEN...ELSE, FOR...NEXT, WHILE...WEND, DO...LOOP, SELECT CASE, END, STOP
LET, DIM, REDIM, CONST, SWAP, DEF FN
PRINT, INPUT, LINE INPUT, INKEY$, LOCATE, CLS, COLOR, WIDTH
SCREEN, PSET, PRESET, LINE, CIRCLE, PAINT, DRAW, PALETTE
BEEP, SOUND, PLAY
OPEN, CLOSE, INPUT#, PRINT#, LINE INPUT#, EOF, LOF
ABS, SGN, INT, FIX, SQR, SIN, COS, TAN, ATN, LOG, EXP, RND, LEN, LEFT$, RIGHT$, MID$, CHR$, ASC, STR$, VAL, INSTR, STRING$, SPACE$, TIMER, DATE$, TIME$
SUB...END SUB, FUNCTION...END FUNCTION, EXIT FOR, EXIT DO, EXIT SUB, EXIT FUNCTION, ELSEIF
- .NET 10 SDK
- Windows (for graphics features in console version)
# Build all projects
dotnet build
# Publish Windows executable (outputs to bin/)
dotnet publish Basic.Cli -c Release
# Publish Web version (outputs to bin/)
dotnet publish Basic.Web -c ReleaseBasic/
├── Basic.Core/ # Interpreter core (platform-independent)
│ ├── Ast/ # Abstract Syntax Tree
│ ├── Lexer.cs # Tokenizer
│ ├── Parser.cs # Parser
│ └── Interpreter.cs # Main interpreter
├── Basic.Windows/ # Windows graphics (GDI, Console API)
├── Basic.Cli/ # Console application
├── Basic.Web/ # Blazor WebAssembly version
├── samples/ # Sample BASIC programs
└── bin/ # Release binaries
The web version runs entirely in the browser using Blazor WebAssembly. Features:
- Full interpreter running client-side
- Canvas-based graphics rendering
- Keyboard input support
- Sample programs included
- No server required after loading
To use: extract basic-web.zip and open index.html in a modern browser.
MIT License
- Microsoft for GW-BASIC and QBasic
- The retrocomputing community for preserving classic BASIC programs