EduGateway(TM) Getting Started with BASIC


This short tutorial will lead you through the process of installing a common version of the BASIC computer language (called QBASIC) onto your computer. These instructions are required for Windows 95 and above because the default installation no longer installs QBASIC automatically. I'll go through the process in great detail, but as an overview, you will (or may) need your Windows 95 or Windows 98 CD to copy the 2 qbasic.* files from the \other\oldmsdos directory of your Windows CD to the \windows\command directory on your hard drive (if they're not already there). This will make them available for use by DOS. I will also make some suggestions on a working directory for your BASIC programs. Now for the details...
Start by inserting your Windows 95 or Windows 98 CD into your CD ROM drive. Depending on your settings, this may automatically begin running the Windows Installation/Upgrade program. If this happens, just cancel, exit, or close all of the dialog boxes and programs that it starts. Eventually you will be back to your normal desktop.

Then you can open a DOS window using the Start Button as shown in the picture on your right (note that you can view an enlarged version of all these pictures by clicking on them and pressing your browser's "Back" button to return here). As shown in the picture, you will start with the Start button and work your way up to Programs and down to MS-DOS Prompt. This will open a DOS window as shown in the next picture.


Once you've got the DOS window opened, you will only need to type a total of 5 commands. Two will copy QBASIC to your hard drive. One will create a working directory for your BASIC files (I suggest calling it \basic), and the last two will put you in the \basic directory and run QBASIC itself.

This picture shows the actual session, but the coloring has been added to show what you will actually type when you install QBASIC (yellow letters), and what you will type each time you want to run QBASIC (red letters). Be sure to type the commands as shown, and be sure to use the "back slash" character ( \ ) and not the normal forward slash.

The picture shows typical commands and responses, but you may encounter differences if, for example, your computer already has QBASIC installed. In that case, the copy command will ask you if you want to overwrite the original files. You may want to answer "No" to see if they work, and then reinstall if the original files don't work properly. You may also have to use a different drive letter for your CD-ROM drive in the copy command. You can find the proper drive letter for your CD-ROM drive by looking in many places including "My Computer". I've used "d" (as in "copy d:\other...") because that's the most likely drive letter for single hard drive computers with CD-ROMs. Here are the commands themselves:

  • cd \windows\command
  • copy d:\other\oldmsdos\qbasic.*
  • md \basic
  • cd \basic
  • qbasic

The last command above is the qbasic command which actually starts the QBASIC program. QBASIC normally starts with a welcome screen as shown in this picture. You can get help if you're interested or just push the Escape key (normally labeled Esc in the upper left corner of your keyboard). At this point your mouse should work within the QBASIC window, but if it doesn't you'll have to rely on your keyboard to navigate the menu. You can use the Alt key to highlight the keyboard hot keys in the menu bar. Then just hit the key that corresponds to the menu you want to select. Many people find this faster than using the mouse anyway. Another trick that might help is to run it in full-screen mode as described below. You can typically toggle in and out of full-screen mode by pressing Alt / Enter in the DOS window.
Before going any further, I also suggest that you select any particular options that you'd like to use in QBASIC. You can do this with the "Options" menu. I suggest selecting Options / Display as shown in the picture to the right. That will let you select colors and more importantly a reasonable tab width for indentation. As you learn to program you will find that good indentation can really help you see and understand how a program is structured.

This next picture shows my preferred settings in the Display Options dialog box. For example, I prefer a black background instead of the default blue. You can see that the Background box has Black selected. I also prefer to use Tab Stops of 2 spaces for each level rather that the default 8. The larger number does make it easier to see the indentations, but you can quickly run out of screen space if you have to indent many levels. With 8 spaces per tab, and 5 levels of indentation that will take up 40 characters (or half of your screen). Many people like to use 3 or 4, and again it's personal preference. Most of the programs at this site will use 2.

Once you've gotten all of your settings selected, you can start typing in your first QBASIC program. I like to use a simple graphics example to demonstrate the capabilities of BASIC programming. I've taught the following little section of code as part of all my introductory classes over the last 10 years. Just type it in as shown here (and in the picture to the right).
SCREEN 12
DO
  x = 640 * RND
  y = 300 + (50 * RND)
  r = 20 + (20 * RND)
  c = 1 + (14 * RND)
  CIRCLE (x, y), r, c
  PRINT ""
LOOP
You may notice that some of your mistakes (if you make any) will cause a pop-up dialog box to appear. This is because of the Syntax Checking feature that is normally selected in the Options menu. I recommend that you leave this enabled because it will find many of your errors for you. You'll also note that the picture shows a blank line between the SCREEN 12 statement and the DO statement. These blank lines can be added anywhere you think they help make the program easier to read and understand.

This last picture shows a snapshot of the program actually running. If you run the program yourself, you'll see that it doesn't just sit there! You can run your program by selecting the Run / Start menu options. Depending on your computer setup, you may also need (or want) to run it as a full-screen DOS application. You can do this by pressing (and holding) the Alt key and then pressing the Enter (or sometimes labeled Return) key. Each time you press this Alt-Enter combination, the DOS window will toggle between full-screen and windowed display mode. The full-screen will usually run much faster and you can stay in that mode while you're running your programs and even while you're writing and editing them.

© 1997-2001 EduGateway(TM)