Qbasic Tutorial: The Basics (recommended for newbies) Intro: Qbasic is one of the easiest programming languages around. It's an old language that runs in DOS. In this tutorial you will learn the very basics and the most commonly used commands. Before we begin you should download Qbasic first (if you haven't already) which is available on this site. Also, you might want to familiarize yourself with the definitions below. Definitions for this first tutorial: CLS - Clears screen END - Ends program PRINT - Prints characters in quotes on screen LPRINT - Prints characters in quotes on the printer INPUT - Saves user input into a variable REM (or ' ) - A note that does not effect your program Variable - Any number that varies (end with % = number, end with $ = character) The CLS Command The easiest but most commonly used command of all! CLS simply clears the current buffer (screen) of anything on it. This command can be used at the beginning of your programs or someplace else such as a SUB (short for subroutine, a mini program inside a big one, we will learn about these and using them later). For an example of the CLS command look at the examples for other commands such as PRINT or LOOP. That should be it for CLS. The END Command Like the CLS command, END should be typed where you want your program to stop (another words, end the program, pretty self-explanatory). For an example, check out others, END will probably be used in all of them. The PRINT Command Another commonly used command to print characters on the screen. This command uses quotes ("") to note the beginning and the end of the PRINT. Example: CLS PRINT "The PRINT command!" END Type this program in Qbasic and hit SHIFT+F5 to run it, or go by the menu. As you can see, the program printed on the screen what was in the quotes. Change what it prints (by changing text in quotes). Get familiar with this command, you will need it often. The LPRINT Command The exact same thing as the PRINT command, but prints what is in the quotes on the printer. Useful! Reminder - Be sure your printer is on when you run this program. Example: CLS PRINT "Now printing message on printer." LPRINT "The LPRINT command!" The INPUT Command This command allows the user to type stuff that is saved as data into variables. With this command, we can make the example above a lot better, try this one. Example: CLS INPUT "What do you want the printer to print?", word$ LPRINT word$ END The input, printed the question on the screen, then had a blinking cursor after it to allow the user to type in something. Then, whatever the user typed in, the text is saved in the variable word$. Play around with this program, find out what works and doesn't. The REM Command A command that does not effect your program, just adds a little footnote. Very useful when your programs get long. Example: REM This program is by me! CLS REM Notice the REM command does not effect your program PRINT "Hello World!" END The REM command can also be used with a ' which I find is easier, because it doesn't stand out like typing in REM. ------- I will have more on this tutorial later.