QBasic

Introduction

These pages are not meant to be an authority on MSDOS QBasic, it is a collection of solutions to problems that I needed to solve. The code presented here may not be the most elegant, but then, at the time it was written problems needed to be solved quickly.

For ease of presentation, and partly because some of this code was never in one, the code is not in formal subroutines. All of it should work "as is" and you may feel free to copy and adapt as much, or as little! as you want.

Why QBasic?

I've been using QBasic for quite a few years and have grown up with it's quirks, ie support for joysticks and sound but nothing for the mouse! Unless, of course you want to delve into the mysteries of Interupts. Although I can use Visual Basic, as I usually write programs to manipulate a variety of data files, I don't need a load of code to make the screen "pretty", a simple "Program in progress - DO NOT switch this machine off" message usually suffices. There are other reasons, our data file disk space is a precious commodity and filling it up with OCX's, VBXs and DLLs is a waste. Another reason is that on modern PCs QBasic is very fast. A couple of days before writing this I had to process a file with 4.5 million records and which was over a gigabyte in length. Processing all of the records took around a quarter of an hour. Obviously, Visual Basic, C++, Delphi and their kind have their uses but for writing small quick utilities then I don't think you can beat QBasic. I should point out that the programs on these pages were written using QBasic v1.1

Obtaining QBasic

QBasic has been included in all versions of DOS. It was included in Windows and there is a version on the Windows 95 CD. Although it is not loaded by default, it can be found in the directory /OTHER/OLDDOS along with the DOS helpfile.

Copies of QBasic versions 1.1, 4.5 and 7.1 are available from my Downloads page.

Ideas for programs

For many people when starting to program the question is "What to program?" I get ideas for my programs from all sorts of places. If I need some sort of utility I'll have a go at writing it myself. If I find a program that I like, I'll have a go at reproducing it. When I do this, if the source code is available I rarely look at it, I like to program from scratch not just alter someone else's code. Sometimes someone will put a post into one of the QBasic forums that will give me an idea for a program.

If you're new to programming it's very tempting to look at a program that's taken someone else a long time to write, such as one of the many RPGs (Role Playing Games) and say "I can do that." Unfortunately, the chances are you can't. Start with something easier, it may be something such as writing a program to display a lot of coloured circles. That doesn't sound very exciting, but you'll learn about the drawing commands, loops and what colours can be displayed. The important thing about programs like this, and I've written a lot of them, is that you learn different aspects of programming in small pieces. If you start off by writing a massive RPG you'll have to learn everything at once, you'll get very frustrated and the chances are it'll never get finished. No matter how simple it is it's always nice to run a program and know that you've written it yourself.

Other pages in this section...

This page created 13th May 1999, last modified 6th May 2014


GoStats stats counter