💻

Senzall's BASIC

Programming Sandbox

A real BASIC interpreter. Write and run programs in the language that started the home computer revolution.

The Environment

Your Terminal

The Green Screen

When you open Senzall's BASIC, you see a classic green-on-black terminal — the same look that greeted millions of home computer users in the late 1970s and early 1980s. A blinking cursor waits at the bottom for you to type.

Everything happens through text. You type commands and programs. The computer responds with text. There are no buttons to click, no menus to navigate — just you and the machine, communicating through a language called BASIC.

The Keyboard

Below the terminal screen you'll find a custom keyboard designed for BASIC programming:

The Learn Button

In the top corner of the screen you'll find the Learn button. Tap it to open a quick-reference card with all the BASIC commands, their syntax, and short examples. It's your cheat sheet while you're learning.

Immediate Commands

Some things you type are executed immediately, without a line number:

LIST 10 PRINT "HELLO" 20 GOTO 10 RUN HELLO HELLO HELLO ...

How Numbered Lines Work

In BASIC, every line of your program starts with a line number. The computer stores lines in numerical order and executes them that way. This is how you build a program:

10 PRINT "FIRST" 20 PRINT "SECOND" 30 PRINT "THIRD"

The numbers don't have to be consecutive. By convention, you number lines by 10s (10, 20, 30...) so you can insert new lines between existing ones later:

10 PRINT "FIRST" 15 PRINT "BETWEEN FIRST AND SECOND" 20 PRINT "SECOND" 30 PRINT "THIRD"

To delete a line, type just its number and press Return. To replace a line, type the same number with new content — it overwrites the old version.


Reference

Complete Language Reference

PRINT

Display text, numbers, and the values of variables on the screen. The most fundamental command in BASIC.

Print a string

10 PRINT "HELLO WORLD"

Print a variable

10 LET X = 42 20 PRINT X

Print an expression

10 PRINT 3 + 4 20 PRINT 10 * 5 - 2

Mix text and values

10 LET N$ = "WORLD" 20 PRINT "HELLO "; N$

Semicolons suppress the newline

Normally each PRINT goes to a new line. A semicolon at the end keeps the cursor on the same line:

10 PRINT "HELLO "; 20 PRINT "WORLD"

Output: HELLO WORLD (on one line)

INPUT

Ask the user to type a value. The program pauses and waits for input.

With a prompt

10 INPUT "WHAT IS YOUR NAME? "; N$ 20 PRINT "HELLO "; N$

Numeric input

10 INPUT "ENTER A NUMBER: "; X 20 PRINT X; " SQUARED IS "; X * X

Use a regular variable name (like X, N, AGE) for numbers. Use a variable ending in $ (like N$, A$, NAME$) for text strings.

LET

Assign a value to a variable. The word LET is optional — both forms work identically.

10 LET X = 10 20 Y = 20 30 LET NAME$ = "STEVE" 40 TOTAL = X + Y 50 PRINT NAME$; " TOTAL: "; TOTAL

Variables can hold numbers or strings. String variable names always end with a dollar sign ($). You can use any math expression on the right side: addition (+), subtraction (-), multiplication (*), division (/), and parentheses for grouping.

GOTO

Jump to a specific line number. Execution continues from that line. This is how you create loops in BASIC.

10 PRINT "THIS REPEATS FOREVER" 20 GOTO 10

This creates an infinite loop — the program prints the message, jumps back to line 10, prints it again, and so on. To stop a running program, tap the Stop button.

IF...THEN

Make decisions. If the condition is true, the command after THEN executes. If false, the program skips to the next line.

Simple comparison

10 INPUT "ENTER A NUMBER: "; X 20 IF X > 100 THEN PRINT "THAT'S A BIG NUMBER" 30 IF X < 0 THEN PRINT "THAT'S NEGATIVE" 40 IF X = 42 THEN PRINT "THE ANSWER!"

Comparison operators

Use = (equal), <> (not equal), < (less than), > (greater than), <= (less or equal), >= (greater or equal).

IF...THEN GOTO

10 INPUT "GUESS: "; G 20 IF G = 7 THEN GOTO 50 30 PRINT "WRONG, TRY AGAIN" 40 GOTO 10 50 PRINT "CORRECT!"

FOR...NEXT

Repeat a block of code a specific number of times. The loop variable counts up (or down) automatically.

Basic loop

10 FOR I = 1 TO 5 20 PRINT I 30 NEXT I

Output: 1, 2, 3, 4, 5 (each on its own line)

Using STEP

10 FOR I = 0 TO 20 STEP 5 20 PRINT I 30 NEXT I

Output: 0, 5, 10, 15, 20. The STEP value controls how much the counter increases each time. Use a negative STEP to count down:

10 FOR I = 10 TO 1 STEP -1 20 PRINT I 30 NEXT I 40 PRINT "LIFTOFF!"

Nested loops

10 FOR ROW = 1 TO 3 20 FOR COL = 1 TO 4 30 PRINT "* "; 40 NEXT COL 50 PRINT 60 NEXT ROW

This prints a 3-by-4 grid of stars. The inner loop (COL) runs completely for each pass of the outer loop (ROW).

GOSUB / RETURN

Call a subroutine. GOSUB jumps to a line number (like GOTO), but RETURN jumps back to where you left off. This lets you reuse code.

10 PRINT "BEFORE SUBROUTINE" 20 GOSUB 100 30 PRINT "AFTER SUBROUTINE" 40 END 100 REM -- MY SUBROUTINE -- 110 PRINT "INSIDE THE SUBROUTINE" 120 RETURN

Line 20 jumps to line 100. Lines 100-120 execute. RETURN on line 120 jumps back to line 30. The END on line 40 prevents the program from accidentally falling into the subroutine again.

REM

Add a comment. Everything after REM on that line is ignored by the interpreter. Use comments to explain your code.

10 REM === NUMBER GUESSING GAME === 20 REM PICK A RANDOM NUMBER 1-100 30 LET N = INT(RND(100)) + 1 40 REM ASK THE PLAYER TO GUESS 50 INPUT "YOUR GUESS: "; G

END and CLS

END stops the program. Use it to prevent execution from falling through into subroutines or data sections at the bottom of your code.

CLS clears the screen. Useful at the beginning of a program or when you want a fresh display.

10 CLS 20 PRINT "WELCOME TO MY PROGRAM" 30 PRINT "PRESS RUN TO START" 40 END

Built-in Functions

Functions take a value and return a result. Use them inside expressions.

Random numbers in practice

10 REM ROLL A DIE (1-6) 20 LET D = INT(RND(6)) + 1 30 PRINT "YOU ROLLED: "; D

String Variables and Concatenation

String variables hold text and always end with a $ sign. You can join strings together using the + operator.

10 LET FIRST$ = "HELLO" 20 LET LAST$ = "WORLD" 30 LET FULL$ = FIRST$ + " " + LAST$ 40 PRINT FULL$ 50 PRINT "LENGTH: "; LEN(FULL$)

Output:

HELLO WORLD LENGTH: 11

Tutorials

Step-by-Step Walkthroughs

Tutorial 1: Your First Program

Let's write the classic first program every programmer writes, then build on it.

Step 1 — Hello World

Type this line and press Return:

10 PRINT "HELLO WORLD"

Nothing visible happens yet — you've just stored line 10 in memory. Now type:

RUN

The screen shows HELLO WORLD. You've just written and executed your first program.

Step 2 — Add more lines

Don't type NEW. Your program is still in memory. Add to it:

20 PRINT "MY NAME IS SENZALL" 30 PRINT "I AM LEARNING BASIC"

Type RUN again. Now it prints all three lines in order.

Step 3 — Use a variable

Let's make it personal. Add these lines:

5 INPUT "WHAT IS YOUR NAME? "; N$ 20 PRINT "HELLO "; N$

Line 5 runs before line 10 (because 5 < 10). Line 20 replaces the old line 20. Type LIST to see your updated program, then RUN it. It asks your name, then greets you.

What you learned

PRINT displays text. INPUT asks for a response. Lines execute in numerical order. You can insert and replace lines anytime.

Tutorial 2: Making Decisions — Number Guessing Game

Let's build a game step by step. Type NEW first to clear any old program.

Step 1 — Pick a secret number

10 REM NUMBER GUESSING GAME 20 LET SECRET = INT(RND(100)) + 1 30 PRINT "I'M THINKING OF A NUMBER 1-100"

Line 20 picks a random number from 1 to 100 and stores it in the variable SECRET.

Step 2 — Ask for a guess

40 INPUT "YOUR GUESS: "; G

Step 3 — Check the guess

50 IF G = SECRET THEN GOTO 100 60 IF G < SECRET THEN PRINT "TOO LOW" 70 IF G > SECRET THEN PRINT "TOO HIGH" 80 GOTO 40

If the guess matches, jump to the win message (line 100). Otherwise, give a hint and loop back to ask again.

Step 4 — The win message

100 PRINT "YOU GOT IT!" 110 PRINT "THE NUMBER WAS "; SECRET 120 END

Run it!

Type RUN. The game picks a secret number, asks you to guess, gives you hints (too high / too low), and congratulates you when you get it right. Type RUN again for a new number.

What you learned

IF...THEN makes decisions. GOTO creates loops. RND generates random numbers. Variables store data that changes as the program runs.

Tutorial 3: Loops and Patterns — Star Pattern Maker

Let's use FOR...NEXT loops to draw patterns on screen. Type NEW first.

Step 1 — A simple row of stars

10 FOR I = 1 TO 10 20 PRINT "* "; 30 NEXT I 40 PRINT

RUN it. You see: * * * * * * * * * *. The semicolon keeps each star on the same line. Line 40's empty PRINT moves to a new line at the end.

Step 2 — A triangle

Type NEW, then enter this program:

10 FOR ROW = 1 TO 5 20 FOR STAR = 1 TO ROW 30 PRINT "* "; 40 NEXT STAR 50 PRINT 60 NEXT ROW

RUN it. Output:

* * * * * * * * * * * * * * *

The outer loop counts rows (1 to 5). The inner loop prints that many stars. Row 1 gets 1 star. Row 2 gets 2 stars. And so on.

Step 3 — Make it interactive

Let the user choose the size. Change line 10:

5 INPUT "HOW MANY ROWS? "; N 10 FOR ROW = 1 TO N

Now RUN it and try different sizes. Try 3. Try 10. Try 20.

Step 4 — Experiment!

Try changing line 30 to print different characters. Try PRINT "# "; or PRINT ROW; " "; to print numbers instead of stars.

What you learned

FOR...NEXT loops repeat code a set number of times. Nested loops (a loop inside a loop) create 2D patterns. The loop variable changes each time through.


Editor

Editor Tips


Samples

The 10 Sample Programs

Type SAMPLES to open the sample browser. Each program demonstrates a different concept. Load one, RUN it, then LIST it to see how it works.


History

A Brief History of BASIC

1964 — Dartmouth College

John Kemeny and Thomas Kurtz created BASIC (Beginner's All-purpose Symbolic Instruction Code) with a radical idea: every student should be able to use a computer, not just science majors. It was designed to be typed in English words, not cryptic symbols.

1975 — Micro-Soft BASIC

A young Bill Gates and Paul Allen wrote a BASIC interpreter for the Altair 8800 — one of the first personal computers. It was Microsoft's first product. That tiny interpreter, running in 4 kilobytes of memory, launched what would become the world's largest software company.

1977-1985 — The Home Computer Era

The Apple II, TRS-80, Commodore 64, BBC Micro, and dozens of other home computers all shipped with BASIC built into ROM. Turn on the machine and BASIC was ready. An entire generation — millions of kids worldwide — learned to program by typing BASIC programs from magazines, books, and their own imagination.

Today

BASIC has evolved into Visual Basic, VBA, and other modern forms. But the original line-numbered BASIC remains a perfect teaching tool — simple enough to learn in an afternoon, powerful enough to build real programs. Every concept you learn here (variables, loops, conditionals, subroutines) maps directly to modern programming languages.


Strategy

Tips

← Back to All Games