This appendix assumes that you have QBasic on your system. See appendix A if you do not.
QBasic was written to run on old Microsoft operating systems, starting with DOS 5.0 and does not behave like modern software. At first this can be frustrating because many of the things you would expect to do with the mouse must be done using a menu.
There are many ways to do the things discussed below. After you have run through the process a few times, feel free to experiment.
This method uses the DOS window, similar to what is done in Appendix A. There are other ways to do this using the windows interface. You can navigate with Windows Navigator to the directory that holds qbasic.exe and click on it to start it.
1A. On your desktop, click on "Start"
1B. Click on Run. Then in the Run dialog box type
and click on OK.
A DOS window (sometimes called a command prompt window) starts up. When it first starts, it will be set up to use a particular part of the hard disk for the QBasic files it may save and read. This is called the default directory. If you are not going to save your program files to the hard disk skip to 1F. If you want to save programs to the hard disk, do the optional steps that follow.
1C. Optional: Change the default directory
to the root directory of
C: (or any other disk) by using the
command followed by a backslash:
1D. Optional: make a new directory to hold
your programs. You only need to do this once. Call the directory QSOURCE
(or any other name you like). Use the
1E. Optional: Change to the directory in which you keep your QBasic source programs. This might be the directory you just created (in step 1D).
Notice that in the DOS window, uppercase and lower case don't matter. The "change directory" command is CD or cd. The directory you change to can be in upper or lower case (or a mix of both).
1F. Start the QBasic system by typing qbasic:
1G. The QBasic development window appears:
1H. Hit ESCAPE (tap the Esc key) to clear the welcome message. (Or, you can hit Enter to explore the on line help of the QBasic system.)
You may have to left-click the mouse in the QBasic window to give it "focus". The window has focus when the top bar of the window is light blue, as seen in 1H. There should also be a yellow underscore blinking in the upper left.
(Note: you will not be able to use your mouse to make selections by clicking on words and icons within the QBasic window. To make selections from the menu, use the "Alt" key followed by the first letter of the menu. Or you can use the arrow keys to change the menu selection. Hit enter to make a selection. Hit Escape to undo a choice. Hit tab to move among choices in a dialog box.)
(The above may sound really awful. But it is easy after you have done it a few times.)
2A. Enter you program by typing on the keyboard. The characters should appear in the window. The example program is:
PRINT "Hello" END
If you type "print" in lower case, the QBasic system will automatically change it to upper case.
If you make mistakes, use the arrow keys on the keyboard to move the cursor (the yellow underscore) to the mistake.
Use the delete (Del) key or the backspace key to remove the mistake and enter
the correct characters.
If the system is confused (and does not accept characters or starts showing menus you don't want) hit the Escape key. You may need to do this in the steps that follow, too.
2B. Run the program by tapping the F5 key (on the top row of the keyboard). The program starts executing statements one by one starting with the first statement. This program prints "Hello" to the screen:
2C. Hit the Enter key (or any other) to return to the QBasic window
2D. (Alternative) Run the program by using the menu system. Tap the Alt key on the keyboard. The first letter of every command on the menu bar should now be white (as seen in 2C, above). Tap the R key. The Run menu will appear:
2E. (Alternative) Hit the S key (or just hit Enter) to run the program. The menu shows shortcuts to do the same thing, Shift+F5 or just F5 alone. The program runs:
Since the program was run once before, the first output (the first "Hello") remains on the screen. Hit return (or any key) to return to the QBasic window (as before).
2F. Debug your program. Typically at this point you will discover
that the output is incorrect. Repeat steps 2A, 2B, and 2C until the program
2G. To exit QBasic without saving your program: Click on the small box that contains an X in the upper right corner of the window.
Another way to exit is to use the QBasic menus: hit Alt+F+x . The system will ask you if you want to save the program, similar to 3B, below.
You know enough now to read the first several chapters of these notes and to play with their example programs. When you start writing your own programs you will need to save programs onto your computer's hard disk. The following sections explain how to do that.
A "source file" is a permanent disk file that contains a program. Unless you save your program to a file, it will be lost forever when you leave the QBasic system. With a short program, this might not matter. But if you are creating a program with dozens of statements you should save it to disk as soon as you can, even before it is completely working.
3A. Tap the Alt key on the keyboard. The first letter of every command on the menu bar should now be white (as seen in 2C, above). Now tap the F key to see the File menu:
(In the above picture, the actual program is covered up by the menu.)
3B. Tap the S key for "Save".
3C. Tap the Y key for "Yes".
3D. Type "hello.bas" as a file name and tap the RETURN key.
Of course, other programs should be give other file names.
3E. If you try to save the program a file that already exists, the system will ask if you really want to do this.
You should be sure this is what you want to do before you hit Enter (or Y). Otherwise tap the N key to go back to 3D.
3F. You can keep saving the program to the same disk file (repeatedly updating it as you make changes) by using the S menu choice. It will not ask you for a new file name each time. If you want to use a NEW file name, pick the Save As option.
This will bring you back to 3C and you can pick a new name for the file.
3G. Push the down arrow on your keyboard until "Exit" is highlighted, and then hit "enter". You will return to the DOS prompt.
You can load QBasic with a program that has been saved as a disk file.
4A. Start QBasic (if needed). Open the File menu by hitting Alt+F
4B. Hit the O key. This brings up the open file dialog:
4C. The dialog shows the QBasic files in the default directory. (In the above, the default directory is C:\QSOURCE). You may see many files in the directory. To select a file, tap the tab key of your keyboard until the cursor (blinking underscore) is in the box labeled "Files". (The tab key is the key above the Caps Lock key on the keyboard.)
Now hit the up and down arrow keys until the file you want is highlighted:
(An alternative way is to just type the file name into the "File Name:" box.
4D. Hit the Enter key. The program in the file should appear in the QBasic window just as it was when you saved it:
Sometimes you have part of a program you would like to copy to another part. Other times you would like to move a few statements to another part of the program. Cut, Copy, and Paste from the Edit menu can be used for this.
5A. Highlight the lines you wish to copy (or cut) by moving the cursor to the first character of the lines. Do this with the arrow keys of the keyboard. The mouse will not work for this.
Now push and hold down the Shift key and move the cursor over the lines you wish to copy. The lines will be highlighted:
5B. Access the Edit menu by hitting Alt+E. Move the menu selection down to Copy:
5C. In the program window, move the cursor to where you wish to paste the line(s) that were copied.
5D. Return to the Edit menu (Alt+E). Move the selection down to Paste.
5E. Hit Enter. The copied line(s) are pasted into the program. You may need to do some fine adjustment with the arrow keys and the delete key.
This is the end of this Appendix. There is much more to the QBasic system. Some topics are covered in the main chapters when they are needed.