Share via


Programming Home Projects with Microsoft Small Basic: Chapter 1: Writing Programs Using Small Basic

Small Basic Small Basic Books > Programming Home Projects with Small Basic > 1: Writing Programs 

Introduction

This chapter is adapted from the book Programming Home Projects with Microsoft Small Basic by Philip Conrod and Lou Tylee.

To purchase this book in its entirety, please see the Computer Science For Kids web site.

 

1. Writing Programs Using Small Basic

Preview

In this first chapter, we will do an overview of how to write a program using Small Basic.  You’ll get a brief history of Small Basic and look into use of the Small Basic development environment.

Introducing Programming Home Projects With Small Basic

In these notes, we will use Small Basic to build many fun projects you can use around your home.  The projects you will build are:

  • Dual-Mode Stopwatch – Measures total and elapsed time.
  • Consumer Loan Assistant – Helps you determine just how much those loans cost you.
  • Flash Card Math Quiz – Practice basic math skills with timed drills.
  • Multiple Choice Exam – Set up exams matching like terms.
  • Blackjack Card Game – The classic casino game.
  • Weight Tracker - Track your weight each day.
  • Home Inventory Manager – Keep track of all the stuff you own for insurance purposes.
  • Snowball Toss Game – A little game using sounds and animation.

Each project will be addressed in a single chapter.  Complete step-by-step instructions covering every project detail will be provided.  Before beginning the projects, however, we will review the Small Basic development environment in the remainder of this chapter.  Then, we provide an overview of the Small Basic programming language (Chapter 2) and instructions on using the Small Basic debugger tools (Chapter 3).  The projects will begin with Chapter 4.

Requirements for Programming Home Projects With Small Basic

Before starting, let’s examine what you need to successfully build the programs included with Programming Home Projects With Small Basic.  As far as computer skills, you should be comfortable working within the Windows environment.  You should know how to run programs, find and create folders, and move and resize windows. 

As far as programming skills, we assume you have had some exposure to computer programming using some language.  If that language is Small Basic, great!!  We offer two tutorials Small Basic for Kids and Beginning Small Basic, that could help you gain that exposure (see our website for details).  But, if you’ve ever programmed in any language (Visual Basic, C, C++, C#, Java, J#, Ada, even FORTRAN), you should be able to follow what’s going on.  Even if you are a veteran programmer, we suggest you go through the first three chapters before attacking the programs.  This review will give you some idea of the terminology we use in referring to different parts of a Small Basic program.

Regarding software requirements, to use Small Basic, you must be using Windows 7, 2000, Windows XP, Windows NT or Windows Vista.  These notes and all programs are developed using Windows Vista and Version 1.0 of  Small Basic.  And, of course, you need to have the Small Basic product installed on your computer. It is available for free download from Microsoft.  Follow this link for complete instructions for downloading and installing Small Basic on your computer:

http://www.smallbasic.com

Introducing Small Basic

In the late 1970’s and early 1980’s, it seems there were computers everywhere with names like Commodore 64, Texas Instruments 99/4A, Atari 400, Coleco Adam, Timex Sinclair and the IBM PC-Jr.  Stores like Sears, JC Penneys and even K Mart sold computers. 

One thing these machines had in common was that they were all programmed in some version of Microsoft’s BASIC.  Each computer had its own fans and own magazines.  Users would wait each month for the next issue of a magazine with BASIC programs you could type into your computer and try at home. 

This was a fun and exciting time for the beginning programmer, but the fun times ended with the introduction of the IBM-PC in the early 1980’s.  Bigger and faster computers brought forth bigger languages and bigger development environments.  These new languages were expensive to acquire and difficult for the beginning programmer to grasp. 

Which brings us to Small Basic, which I would call a relative of the early, original BASIC language.  The development of Small Basic is an attempt to rekindle the exciting days when just about anyone could sit down at a computer and write a simple program using the BASIC language. 

Those of you who wrote programs on those old “toy” computers will recognize the simplicity of the Small Basic language and the ease of its use.  And, you will also notice Small Basic is a great environment for writing and testing code, something missing in the early 1980’s.  For those of you new to programming, I hope you can feel the excitement we old timers once had.  For the old timers, I hope you rekindle your programming skills with this new product.

Small Basic possesses many features of more powerful (and more expensive) programming languages:

  • Easy-to-use, Integrated Development Environment (IDE)
  • Response to mouse and keyboard actions
  • Full array of mathematical, string handling, and graphics functions
  • Can easily work with arrays
  • Sequential file support

Starting Small Basic

We assume you have Small Basic installed and operational on your computer.  Once installed, to start Small Basic:

  • Click on the Start button on the Windows task bar
  • Select Programs, then Small Basic
  • Click on Microsoft Small Basic

(Some of the headings given here may differ slightly on your computer, but you should have no trouble finding the correct ones.)  The Small Basic program should start.

After installation and trying to start, you may see an error message that announces Small Basic cannot be started.  If this occurs, try downloading and installing the latest version of the Microsoft .NET framework at:

http://msdn.microsoft.com/en-us/netframework/aa569263.aspx

This contains some files that Small Basic needs to operate and such files may not be on your computer.

Upon starting, my screen shows:

This window displays the Small Basic Development Environment.  There are many areas of interest on the screen.  At the top of the window is the Title Bar.  The title bar gives us information about what program we’re using and what Small Basic program we are working with. 

Below the title bar is a Toolbar.  Here, little buttons with pictures allow us to control Small Basic. 

In the middle of the screen is the Editor.  This is where we will write our Small Basic programs.  To the right is a Help area.  Small Basic has great help features when writing programs.  This area will display hints and tips while we write code.

Running a Small Basic Program

Let’s write our first Small Basic program.  When you start, a new editor window appears.  You can also get a new editor window by clicking the New toolbar button.  Type these two lines in the editor window:

TextWindow.Title = "Hello Program"

TextWindow.WriteLine("This is the first line of the program.")

The editor window should look like this:

Notice as you started typing the first line, this popped-up:

Small Basic has “intellisense” and uses this to make typing suggestions.  You can just keep typing or accept its suggestion by scrolling through the pop-up list and pressing the Enter key.

Also, notice this appeared in the help area: 

Once you typed TextWindow, the help feature displayed all it knows about the TextWindow to help you in your programming.

The TextWindow is a Small Basic object.  It displays text output.  The object has properties, methods and events.  There are many objects in Small Basic.  They will be reviewed in Chapter 2.

Let’s run the program.  Simply click the Run button on the toolbar to see:

This is the text window displaying the program output.  I have resized the window a bit.  To stop the program, click the X in the upper right corner of the window.

That’s all there is to writing a Small Basic program.  Type the code in the editor window.  Click the Run button to run the code.  We will learn a lot of Small Basic code as we build the games in this course.  Chapter 3 reviews most elements of the Small Basic language.

Other useful toolbar buttons are:

Open – Open a previously saved Small Basic program

Save – Save a Small Basic program

Save As – Save a Small Basic program with a different name

We suggest saving each Small Basic program in its own folder. 

There are also the Cut, Copy, Paste, Undo, and Redo buttons for common editing tasks.  Learn to use these – they will save you lots of time typing code.

Chapter Review

This completes our overview of the Small Basic environment and a brief demonstration of how to write a Small Basic program.  If you’ve used Small Basic before, this material should be familiar.  If you’ve programmed with other languages, you should have a fairly clear understanding of what’s going on.

After completing this chapter, you should understand:

  • A little of the history of Small Basic.
  • The various parts of the Small Basic integrated development environment.
  • The utility of “intellisense” and the Small Basic help panel.
  • How to write code using the code editor.
  • How to run a Small Basic program.

Before starting the home projects in Chapter 4, we need to review the language of Small Basic (Chapter 2) and learn how to debug projects (Chapter 3).

Excerpt © Copyright 2010-2013 By Kidware Software LLC All Rights Reserved. Computer Science For Kids, the Computer Science For Kids logo, and related trade dress are trademarks or registered trademarks of Kidware Software LLC. Philip Conrod & Lou Tylee have co-authored dozens of books and tutorials for beginning Microsoft Basic, Small Basic, Visual Basic, and Visual C# developers of all ages for over 25 years.