BEGINNING SMALL BASIC
PROGRAMMING TUTORIAL
TABLE OF CONTENTS
1. Introducing Small Basic
Preview 1-1
Why Learn Small Basic? 1-2
A Brief History of Small Basic 1-4
Let’s Get Started 1-12
Downloading and Installing Small Basic 1-14
Starting Small Basic 1-18
Opening a Small Basic Program 1-21
Running a Small Basic Program 1-23
Stopping Small Basic 1-25
Summary 1-26
2. Small Basic Program Basics
Review and Preview 2-1
The Welcome Program (Revisited) 2-2
Some Rules of Small Basic Programming 2-5
Creating Small Basic Programs 2-7
Saving Small Basic Programs 2-12
Small Basic Files 2-15
Review and Preview 2-16
The Welcome Program (Revisited) 2-2
3. Your First Small Basic Program
Review and Preview 3-1
Creating a Small Basic Program 3-2
Small Basic – The First Lesson 3-6
Variables 3-6
Variable Names 3-7
Variable Types 3-8
Assignment Statement 3-10
Arithmetic Operators 3-11
String Concatenation 3-15
Comments 3-16
Program Output 3-17
Program – Sub Sandwich Party 3-21
Program Design 3-21
Program Development 3-22
Run the Program 3-25
Other Things to Try 3-26
Summary 3-28
4. Small Basic Program Design, Input Methods
Review and Preview 4-1
Program Design 4-2
Small Basic – The Second Lesson 4-4
Mathematical Functions 4-4
Program Input Methods 4-9
Input Methods Example 4-10
Program – Savings Calculator 4-14
Program Design 4-14
Program Development 4-15
Run the Program 4-18
Other Things to Try 4-20
Summary 4-22
5. Debugging, Decisions, Random Numbers
Review and Preview 5-1
Debugging a Small Basic Program 5-2
Syntax Errors 5-3
Run-Time Errors 5-6
Logic Errors 5-9
Small Basic – The Third Lesson 5-10
Logical Expressions 5-10
Comparison Operators 5-11
Logical Operators 5-14
Decisions – The If Statement 5-19
Random Number Generator 5-24
Program – Guess the Number Game 5-27
Program Design 5-27
Program Development 5-28
Run the Program 5-31
Other Things to Try 5-32
Summary 5-34
6. Small Basic Looping, Subroutines
Review and Preview 6-1
Small Basic -The Fourth Lesson 6-2
Small Basic Loops 6-2
A Brief Interlude – Guess the Number Game (Revisited) 6-12
Small Basic – The Fourth Lesson (Continued) 6-14
Small Basic Subroutines 6-14
Program – Lemonade Stand 6-18
Program Design 6-19
Program Development 6-20
Run the Program 6-27
Other Things to Try 6-29
Summary 6-30
7. More Small Basic Looping, Arrays
Review and Preview 7-1
Small Basic -The Fifth Lesson 7-2
Small Basic For Loops 7-2
Variable Arrays 7-6
“Shuffle” Method 7-11
Program – Card Wars 7-18
Program Design 7-18
Program Development 7-19
Run the Program 7-27
Other Things to Try 7-29
Summary 7-30
8. Small Basic Graphics, Mouse Methods
Review and Preview 8-1
Graphic User Interfaces (GUI) 8-2
Small Basic Graphics 8-7
Graphics Window 8-7
Colors 8-9
Pen Object 8-10
Graphics Coordinates 8-11
DrawLine Method 8-12
DrawRectangle Method 8-16
Brush Object 8-19
FillRectangle Method 8-19
Clear Method 8-22
Small Basic -The Sixth Lesson 8-23
Mouse Events 8-23
MouseDown Event 8-23
Mouse Properties 8-26
MouseMove Event 8-30
Program -Blackboard Fun 8-33
Program Design 8-33
Program Development 8-34
Run the Program 8-44
Other Things to Try 8-46
Summary 8-49
9. Timers, Animation, Keyboard Methods
Review and Preview 9-1
Timer Object 9-2
Small Basic – The Final Lesson 9-10
DrawText Method 9-10
Animation 9-12
Object Disappearance 9-21
Border Crossing 9-24
Object Erasure 9-28
Collision Detection 9-29
Keyboard Methods 9-34
KeyDown Event 9-34
Program – Balloons 9-39
Program Design 9-39
Program Development 9-40
Run the Program 9-56
Other Things to Try 9-58
Sharing a Small Basic Program 9-60
Summary 9-69
10. More Programs
Preview 10-1
Program 1 – Computer Stopwatch 10-2
Program 2 – Loan Calculator 10-5
Program 3 – Units Conversion 10-8
Program 4 – Times Tables 10-11
Program 5 – State Capitals 10-14
Program 6 – Dice Rolling 10-20
Program 7 – Memory Game 10-24
Program 8 – Tic-Tac-Toe 10-30
Program 9 – Decode 10-35
11. Introduction to Advanced Programming Languages
Preview 11-1
Program 1 – ACEY DUCEY 11-7
Small Basic 11-8
Visual Basic 11-12
Visual C# 11-24
Java 11-30
BASIC 11-35
Program 2 – EVEN WINS 11-37
Small Basic 11-38
Visual Basic 11-41
Visual C# 11-51
Java 11-58
BASIC 11-62
Program 3 – MUGWUMP 11-65
Small Basic 11-66
Visual Basic 11-69
Visual C# 11-77
Java 11-82
BASIC 11-86
Program 4 – LUNAR LANDER 11-87
Small Basic 11-88
Visual Basic 11-91
Visual C# 11-101
Java 11-106
BASIC 11-109
Appendix I. Small Basic Colors