AI Generate BASIC docs instantly

BASIC Cheat Sheet

Quick reference guide with copy-paste ready code snippets

Try DocuWriter Free

Getting Started

3 snippets

Classic BASIC fundamentals

Hello World

10 PRINT "Hello, World!"
20 END

Line Numbers

10 REM Program starts here
20 PRINT "Line 20"
30 PRINT "Line 30"
40 END

REM Comments

10 REM This is a comment
20 PRINT "Code" REM Inline comment
30 END

Variables & Data Types

3 snippets

Variable declarations

Numeric Variables

10 LET X = 10
20 LET Y = 3.14
30 LET TOTAL = X + Y
40 PRINT TOTAL
50 END

String Variables

10 LET NAME$ = "John Doe"
20 LET MESSAGE$ = "Hello, " + NAME$
30 PRINT MESSAGE$
40 END

Arrays

10 DIM NUMBERS(10)
20 DIM NAMES$(5)
30 LET NUMBERS(1) = 100
40 LET NAMES$(1) = "Alice"
50 END

Input & Output

2 snippets

User interaction

PRINT Statement

10 PRINT "Hello"
20 PRINT "Value:", 100
30 PRINT "A"; "B"; "C" REM No spaces
40 PRINT "X", "Y", "Z" REM Tab separated
50 END

INPUT Statement

10 INPUT "Enter your name: ", NAME$
20 INPUT "Enter your age: ", AGE
30 PRINT "Hello, "; NAME$
40 PRINT "You are "; AGE; " years old"
50 END

Tired of looking up syntax?

DocuWriter.ai generates documentation and explains code using AI.

Try Free

Control Flow

3 snippets

Conditionals and branching

IF-THEN

10 INPUT "Enter age: ", AGE
20 IF AGE >= 18 THEN PRINT "Adult"
30 IF AGE < 18 THEN PRINT "Minor"
40 END

IF-THEN-ELSE

10 INPUT "Enter age: ", AGE
20 IF AGE >= 18 THEN GOTO 50
30 PRINT "Minor"
40 GOTO 60
50 PRINT "Adult"
60 END

ON-GOTO

10 INPUT "Select (1-3): ", CHOICE
20 ON CHOICE GOTO 100, 200, 300
30 PRINT "Invalid choice"
40 GOTO 400
100 PRINT "Option 1"
110 GOTO 400
200 PRINT "Option 2"
210 GOTO 400
300 PRINT "Option 3"
400 END

Loops

4 snippets

FOR and WHILE loops

FOR Loop

10 FOR I = 1 TO 10
20 PRINT I
30 NEXT I
40 END

FOR with STEP

10 FOR I = 0 TO 100 STEP 10
20 PRINT I
30 NEXT I
40 END

WHILE Loop (GOTO)

10 LET I = 1
20 IF I > 10 THEN GOTO 60
30 PRINT I
40 LET I = I + 1
50 GOTO 20
60 END

Nested Loops

10 FOR I = 1 TO 3
20 FOR J = 1 TO 3
30 PRINT I; ","; J
40 NEXT J
50 NEXT I
60 END

GOSUB & RETURN

2 snippets

Subroutines

Basic Subroutine

10 GOSUB 100
20 GOSUB 200
30 END
100 PRINT "Subroutine 1"
110 RETURN
200 PRINT "Subroutine 2"
210 RETURN

Subroutine with Data

10 LET X = 10
20 LET Y = 20
30 GOSUB 100
40 PRINT "Result:", RESULT
50 END
100 REM Add subroutine
110 LET RESULT = X + Y
120 RETURN

String Functions

3 snippets

String manipulation

LEFT$, RIGHT$, MID$

10 LET TEXT$ = "Hello World"
20 LET L$ = LEFT$(TEXT$, 5)  REM "Hello"
30 LET R$ = RIGHT$(TEXT$, 5) REM "World"
40 LET M$ = MID$(TEXT$, 7, 5) REM "World"
50 END

LEN Function

10 LET TEXT$ = "Hello"
20 LET LENGTH = LEN(TEXT$)
30 PRINT "Length:", LENGTH REM 5
40 END

String Concatenation

10 LET FIRST$ = "John"
20 LET LAST$ = "Doe"
30 LET FULL$ = FIRST$ + " " + LAST$
40 PRINT FULL$ REM "John Doe"
50 END

Math Functions

2 snippets

Mathematical operations

Basic Math

10 PRINT "10 + 5 =", 10 + 5
20 PRINT "10 - 5 =", 10 - 5
30 PRINT "10 * 5 =", 10 * 5
40 PRINT "10 / 5 =", 10 / 5
50 PRINT "10 ^ 2 =", 10 ^ 2 REM Power
60 END

Math Functions

10 PRINT "ABS(-10):", ABS(-10)
20 PRINT "SQR(16):", SQR(16) REM Square root
30 PRINT "INT(3.7):", INT(3.7)
40 PRINT "RND:", RND REM Random 0-1
50 END

More Cheat Sheets

FAQ

Frequently asked questions

What is a BASIC cheat sheet?

A BASIC cheat sheet is a quick reference guide containing the most commonly used syntax, functions, and patterns in BASIC. It helps developers quickly look up syntax without searching through documentation.

How do I learn BASIC quickly?

Start with the basics: variables, control flow, and functions. Use this cheat sheet as a reference while practicing. For faster learning, try DocuWriter.ai to automatically explain code and generate documentation as you learn.

What are the most important BASIC concepts?

Key BASIC concepts include variables and data types, control flow (if/else, loops), functions, error handling, and working with data structures like arrays and objects/dictionaries.

How can I document my BASIC code?

Use inline comments for complex logic, docstrings for functions and classes, and README files for projects. DocuWriter.ai can automatically generate professional documentation from your BASIC code using AI.

Code Conversion Tools

Convert BASIC to Other Languages

Easily translate your BASIC code to other programming languages with our AI-powered converters

Related resources

Stop memorizing. Start shipping.

Generate BASIC Docs with AI

DocuWriter.ai automatically generates comments, docstrings, and README files for your code.

Auto-generate comments
Create README files
Explain complex code
API documentation
Start Free - No Credit Card

Join 33,700+ developers saving hours every week