Introduction to MS-DOS QBasic Computer Programming Language

So you've finally acquired that IBM PC-compatible computer, and want to know how to program it. Or perhaps you've had it for a while and are getting tired of running everybody else's programs. Or maybe you want it to do something very specific, but nobody seems to have a program that does what you want. That is why you have surfed to these pages. They will teach you, step by step, command by command, a large part of the the QBASIC language. There is one small catch, however, and it is quite minor. I even hesitate to call it a "catch". You must be willing and eager to learn the language.

In the QBASIC programming language series, we will start out relatively fast at the beginning, introducing three commands and explaining constants and numeric variables. We start out relatively fast so that you can begin writing small programs right away, instead of having to wait for two or three web pages to learn all the necessary commands. In fact, the first command that is discussed, the PRINT command, is not fully explored. This way, you will have the tools necessary to write programs, yet not be overwhelmed with the flexibility of the commands. Because of that, many commands will be "introduced" twice - once early on to teach you the basic command, and then again later on to explore the more advanced options that the command allows. We will also introduce more advanced features of QBASIC near the end of the series, including Boolean operators, trigonometric functions, etc. Although we will touch on it briefly, it is beyond the scope of this series to thoroughly teach concepts of flowcharting, recursive programming, etc.

Before we begin, I would first like to wish you luck with learning this new language (but does luck really come into play?), and to tell you that it is Very Important that you read these chapters while sitting in front of your computer actually doing the exercises. Print these pages out so you can read them while using QBASIC! You won't learn just by reading. Also, don't be afraid to try things on your own. Try changing the numbers around that are presented in the examples, and see how the computer responds! That is the best way to learn!! Experiment! As you go along, try changing around something in the program and then predict what the outcome will be - that is a great way to really test your knowledge of a command. In short, learn by doing! It is the best way to retain knowledge! You only remember about 25% to 30% of what you hear, about 50% of what you read or see, but about 75% to 80% of what you do!

Notice that these pages are called "Chapters". Since the chapters are all laid out in a logical manner, each chapter building on the commands and functions learned in previous chapters, it makes a great "quick-reference" guide, but goes one up of most other quick references by including a full explanation of the command and includes examples of how to use the command. It bridges the gap between an overly brief quick reference guide and a very dry, not too understandable and sometimes still sparsely-explained QBASIC reference manual.

Because these chapters do build upon the ones that come before it, we didn't contruct a table of contents - Instead, you should page through all of the screens in order. If too many people complain. we'll throw in a TOC.

Just a word about printing conventions used in these chapters. The regular body of the text is in this font, with emphasized words in italics. Information that you will type in will be in a bold font. Program output will be in this font. New BASIC key words will be printed in a bold face serif font. There is one exception to this general rule. Program listings of more than five lines that you will type in will be printed in the serif font.

Again, we wish you well in your venture to become just a bit more computer literate. While this is not overly hard work, it will take a little bit of persistence, or stick-to-it-iveness, if you prefer. Above all, however, have fun!! Don't just try the examples in this series, but see if you can write some interesting programs of your own! Since QBASIC is a strong engineering language (that means it is loaded with mathematical functions), you will be able to solve complex mathematical problems. With the power of looping and the quick speed of the computer, many redundant and recursive math functions will be performed quickly and with very little effort. In fact, one example program in the booklet calculates a square root of a number simply by repeated division that zeroes in on the answer. This is an example of recursive programming. That means the program keeps running through the same set of instructions continuously until a certain condition is met (In this case, the accuracy of the solution). There is no way of knowing how many times the instructions will be cycled through, and in fact will be different for almost every different value that is plugged into the formula!

By the way, beginning with chapter 6, some of the larger or more useful/interesting programs will have a big red arrow next to them indicating that you can download the program ("source code" in programmer-ese) right off of the internet! They are all very small - the largest is the cash register program in chapter 12, at only 2,091 bytes! should take about 1/2 second at 28.8k.

Now sit down in front of your computer, turn it on, get Chapter One ready, stretch out your fingers over the keyboard, and let's have some fun!

Advance to Chapter 1