Welcome to the third in a series of computer lessons designed specifically for the Anthracite Area Computer Club. These lessons review and build on the computer classes that were held in the Mount Carmel Public Library from December 26, 1994 through January 2, 1995. While this document is freely available for non-profit use within the Anthracite Area Computer Club, it remains the intellectual property of its author. The author retains all copyrights as well. |
NOTE: This series of lessons includes an optional Typing Lesson and an optional Mouse Lesson. If you are not familiar with using a keyboard or a mouse, you may want to practice with those lessons before starting. Even if you have used a mouse before, these lessons may improve your skill. |
As you may recall from lesson 1, people use Computer Languages to give instructions that the computer will follow. You may also recall that BASIC is one of the most popular languages in use today. This lesson will teach you how to use the QBASIC environment to tell the computer what to do. For this lesson you should insert the disk labeled "AACC Lesson 3" into the floppy disk drive, gently twist the floppy disk drive door handle down, and turn the computer power switch on (flip the switch upward for "on"). After a little while you should see the following welcome screen for QBASIC.
The Welcome Screen will only appear when you first start QBASIC. As the screen says, you can press the enter key to see the Survival Guide, or you can press ESC (escape) to clear the Welcome Screen. In this case, press the ESC key to clear the dialog box. After pressing the escape key (Esc) the screen should look like this:
There should be a small horizontal blinking line that looks like this: " " located in the upper left area of the screen. This blinking line is called the Text Cursor. You can think of the text cursor as the place where the keyboard is connected to the screen. As such, the text cursor indicates the position where new letters typed at the keyboard will appear on the screen and where letters will be removed with the delete key (usually marked "Del") or the backspace key (usually marked "Backspace" or "<--"). There is a slight difference between the delete and backspace keys, and for now it is easiest to always use the backspace key. Try typing the letters "abc", then press the backspace key repeatedly to remove all three letters. This shows you a simple way to fix typing mistakes: Use the backspace key to erase what you want to change. When you are done your screen should still look like the picture above.
At this point you should check to see that your mouse is working.
The following picture shows a typical mouse with three buttons (some mice have
only two buttons since the middle button is rarely used).
Now you are ready to type in your first instruction to the computer. In this case, you will type in the "clear screen" instruction which is abbreviated as "cls". Type it in as shown in the screen below.
After you have typed in "cls", press the return key (often labeled as "Enter" or with a reverse L shaped arrow). When you press the return key, the cursor ( ) will move to the next line, and the letters "cls" should be capitalized:
This capitalization indicates that QBASIC recognizes the word as an instruction it can follow. In this case, QBASIC has recognized that CLS is a valid QBASIC instruction. Now type in the following instruction:
print "Hello World!"
and then press the return key. Again, you will notice that the cursor moves to the beginning of the next line, and that QBASIC has capitalized the word PRINT. This indicates that QBASIC recognizes the word PRINT as an instruction it can follow. The other letters (inside the double quotes) are not changed because they are not instructions themselves. Your screen should look like this:
Now it's time to ask the computer to follow these instructions. This is done using the Run and Start menu selections. First move your mouse on to any letter in the word "Run" on the top menu bar. Then hold the mouse steady with your hand while you click the left mouse button once (the word "click" means press the button and release it again quickly). This will cause the three different run options to drop down from the menu bar as shown in the next picture. Now move your mouse cursor onto the word "Start" and click the left mouse button again. This tells the computer to start following the instructions that you typed in.
If everything went well, the computer screen should have gone blank, and then the words "Hello World!" should have appeared in the upper left corner of the screen. Just after that the words "Press any key to continue" should have appeared in the lower left corner of the screen as shown in the next picture.
At this point the computer has followed your instructions! First it cleared the output screen in response to your CLS instruction. Then it printed the words that you told it to print (Hello World!). After completing its work, the computer waits for you to press a key. This gives you a chance to see what the computer has done. Now press the space bar, and the screen should return to QBASIC as shown below:
Now let's try switching the screen display between what our program is and what our program does. We can do this by pressing the key labeled "F4" on the left side (or top) of your keyboard. Press it once now. You should see a blank screen that says "Hello World!" in the upper left. This screen is called the output screen because it shows us the output from our program. In other words, it shows us what our program did. Now press the F4 key again. Now the screen should show the list of two instructions (CLS, and PRINT "Hello World!") that make up our program (remember from lesson 1 that a Computer Program is a list of Computer Language Instructions). This list of instructions is what our program is. Now press the F4 key again. The display should again switch back to the output screen. Press F4 again, and the display should switch back to the program screen. This shows that the F4 key acts like a toggle key because it toggles back and forth between the output screen and the program screen. Press it again and again to get comfortable with how it works. This will also help you get used to the difference between what a program is and what a program does. A program is a list of instructions. The results of those instructions is what the program does. As you learned in lesson 1, a computer is a chameleon that can do many different things. It is the list of instructions (or program) that determines what the computer will really do. These lists of instructions are also called Software. The name "software" was chosen as a contrast to the term Hardware which refers to the physical components of the computer (like the keyboard or the screen). Hardware is always something that you can touch. You can't really touch software since it is just a list of instructions.
Now let's add some more PRINT instructions to the program. First be sure that you are looking at the program screen (the last picture on the previous page). Your list of instructions should look like this:
CLS PRINT "Hello World!" _
Your blinking text cursor ( ) should be below the word PRINT as shown above. Now type the following (remember to end each line with the return key):
print "A Computer is a Machine that Follows Instructions." print "A Computer Language is how People Give Instructions to Computers." print "A Computer Program is a List of Computer Language Instructions."
Each time that you press the return key you will notice that the word "print" will automatically change to capital letters (PRINT) indicating that QBASIC recognizes that word as an instruction. When you have typed in all three lines, your screen should look like this:
Now let's have the computer follow these instructions. We'll start by looking at what is showing on the output screen. Press the F4 key once. You should see the results of our last program (which should say "Hello World!" the first time through). Press the F4 key again to return to the program screen.
Now use the mouse to click on the Run option in the top menu bar. The Run options should drop down from the menu bar listing "Start", "Restart", and "Continue". Use the mouse to click on the word "Start" which should produce the results below:
Again the computer followed our instructions by clearing the screen and printing out the 4 sentences that we requested. Again the computer waits for us to look at the results as indicated with the message: "Press any key to continue". At this point press the space bar to return to the program screen. Your screen should look like this again:
Now let's watch the computer as it follows each instruction step by step. First restart the program by using the mouse to click on Run (in the top menu bar), and then clicking on Restart (in the drop down box):
This will cause the computer to "restart" the program from the top. The restart instruction also tells the computer that you want it to follow your instructions one step at a time. This is called single step mode because we want the computer to take a single step at a time (single step mode is also called "debug mode" because it can help a programmer to get the "bugs" out of a program). When the computer is in single step mode it will wait for you to tell it to follow the next instruction. The computer will show you the next instruction by making it brighter (or by changing its color on color computers). This next picture shows what your screen should look like after you clicked on the "Restart" command. Notice that the first instruction (CLS) is brighter than all the other instructions. This tells you which instruction the computer will do next. In other words, the computer is waiting for you to tell it to do the "CLS" instruction. Now watch the screen as you press the "F8" key on the left side (or top) of your keyboard and observe what happens.
You should have seen the screen flash for a brief instant, and then it should look like the screen below:
The "F8" key tells the computer to do the next instruction (or step). Before you pressed F8, the computer was waiting to do the CLS instruction. When you pressed F8, the computer did the CLS instruction (that was the brief flash of the screen). It then went on to the next instruction where it is currently waiting. As you may remember, the CLS instruction tells the computer to clear the screen. Let's take a look at the output screen to see if it worked. Press the F4 key one time, and you should see a blank screen (all black). Sure enough, the computer followed our instruction and cleared the screen! Now press the F4 key again to get back to the program screen. The computer should still be waiting to follow the next instruction which is: PRINT "Hello World!". You can tell that the computer is waiting on that instruction because it is highlighted as shown in the previous picture. Now press F8 again. Once again the screen should flash quickly, and the next instruction should be highlighted as shown in the picture below.
This means that the computer should have already followed our last instruction. Let's verify that. Press F4 once. You should see a blank screen with the words:
Hello World!
in the upper left corner. This is the result of the instruction that told the computer to print "Hello World!". This is a verification that it did what we told it to do. It printed "Hello World!" just as we asked it to do. Now press F4 again to get back to the program screen as shown here (same as above):
Now the computer is waiting to do the next instruction which is to print our first definition (from Lesson 1). Press F8 one time and the computer will do it. Again you should see a brief flash while the computer prints our first definition to the screen. After the flash, the program screen should look like the picture below:
Again let's make a quick check to verify that the computer did what we told it. Press the F4 key once and you should see the following words in the upper left corner of the screen:
Hello World! A Computer is a Machine that Follows Instructions.
Now press the F4 key again to get back into the program screen (which should still look like the last picture on the previous page). The computer should still be waiting to do the next instruction as indicated by the highlight of the fourth instruction of our program (shown in the previous picture). The highlight shows that the computer is ready to print this sentence: "A Computer Language is how People Give Instructions to Computers."
Now watch the screen carefully and press the F8 key again. The screen should flash again as it prints out the definition of a computer language. Depending on the speed of your computer, you may actually be able to see it print out the definition. After the flash, the screen should look like the following picture:
Because the computer is now waiting to do the last instruction we can expect that it has already done the "next-to-last" instruction. In other words, it should have already printed our second definition which states that "A Computer Language is how People Give Instructions to Computers". Let's verify that by pressing F4 once to see the output screen. You should see:
Hello World! A Computer is a Machine that Follows Instructions. A Computer Language is how People Give Instructions to Computers.
As we expected, the computer has printed out our Computer Language definition (which was the fourth instruction of the computer program). Now press F4 again to return to the program screen which should still look like the picture above. The highlight still shows that the computer is ready to execute our last instruction. This last instruction tells the computer to print our definition of a Computer Program (A Computer Program is a list of Computer language Instructions). Now watch the screen and press the F8 key one more time. You should see the final result of our program as shown here:
Notice that this time the computer doesn't just flash the screen, but waits for you to press a key. This is because the computer has reached the end of your instructions and is showing you the results. Press the F4 key one more time to return to the program screen as shown below.
Now you have stepped all the way through the program one instruction at a time! If you have some more time, you can run through the program again fairly easily by going back to where you used the mouse to click on the Run and Restart options. If you do go back, simply follow along from there until you get back here again. At that point you can continue to go back and do it again and again to improve your understanding of how the computer follows instructions. When you are done you should go on to the next sections which will tell you how to turn off the computer and give you a short review.
How to turn the Computer Off:
This has been a long lesson, but there is one more thing that you should learn how to do. You need to learn how to shut the computer off properly. This involves a few simple steps. First you will need to exit from QBASIC. Use the mouse to click on the File option in the top menu bar (it should be the first option on the left). When you click on the word "File", the following menu should drop down from the menu bar:
This is called the File menu, and contains several important options that you will learn about in later lessons. The most important of these options is the "Exit" option at the bottom of the list. The Exit option will get you out of the QBASIC environment and return you to the DOS environment (you will learn more about this in later lessons). Now use your mouse to click on the word "Exit". The computer will then pop up a question box that asks if you want to save your work. Normally you would answer Yes, but for this exercise you should answer No. You can answer no by using the left mouse button to click on the word: "< No >" that appears inside the popup box (or you can press the "n" key on your keyboard).
This should bring you back to the DOS screen which should look something like this:
Next type in the following command (Note: Most newer computers can skip this step):
park
and press the return key (often labeled as "Enter" or with a reverse L shaped arrow). The park command will run a special program that protects the hard disk drive if the computer is bumped or moved. While using park is not critical, it is a good habit to develop (just like brushing your teeth). And just like toothpaste, there are many different "brands" of the park program. Most versions will ask if you are sure that you want to park the disks. If it asks you a question you should respond appropriately (usually with a "y" for yes or an "n" for no). Most versions will then let you know that the disk is parked. The park program is usually self-explanatory, so simply follow the instructions for the version of park that your system uses.
When the disk is parked you can turn the power switch off. Don't forget to remove the floppy disk from the floppy disk drive. Open the disk drive door handle by gently twisting to the right and up. Then pull out the floppy disk and put it back into its protective paper envelope.
This lesson has covered the following topics and skills: