Site hosted by Angelfire.com: Build your free website today!
Chapter Two
Tutorials

[WHAT'S NEW] [FAQ] [AWARDS] [TUTORIALS] [GAMES] [LINKS]
[PROJECTS] [CONTESTS] [FEEDBACK]

asic screen.

The first, and probably most important thing you have to learn is CLS. This is a command usually typed at the first of your program. CLS stands for clear screen, and that's exactly what it does. It gives you a clear black screen. Type CLS in the body and press F5. You should see a blank screen with a "Press any key to continue" message at the bottom. You're doing good if you get this message.

Moving on. You've already learned how to clear the screen. Now, say you want to print something on the screen. How would you do that? The answer is simple and you'll understand right away. To print a message, type in "PRINT" on your screen. Now, type a space and write something in quotation marks. Example:

CLS
PRINT "HELLO, WORLD!"

Now, press Enter and type another PRINT command.

CLS
PRINT "HELLO, WORLD!"
PRINT "My name is Bob."

Now, press F5. Aha! You will see at the top of the screen what you wrote!

HELLO, WORLD!
My name is Bob.

Notice that there are no CLS or PRINTs on the screen, and those quotation marks are gone. CLS and PRINT are what we call commands, and you can't program without them. Congratulations! You've just made your first program, despite its size.

Now, say you want to put blank lines between your messages. How would you do that? You'd have to type "PRINT" between your messages. No quotation marks, no words.

CLS
PRINT "HELLO, WORLD!"
PRINT
PRINT "My name is Bob."

And your result is...

HELLO, WORLD!

My name is Bob.

Simple, eh? Practice writing other things out with your PRINT commands, until you get the jist of it. Now, while we are on the topic of text in QBasic, we'll go ahead and work on the LOCATE commands. What's that? Well, a LOCATE command is another convenient little doohickey that lets you spread your text out all over the screen. Type "LOCATE 5, 4" before a PRINT command and press F5. What happens?

|
|
|
|
|
----In your program, LOCATE sets your text to other places on the screen.

For LOCATE commands, you have to learn this: LOCATE [up/down], [right/left] As you can see from that text demo I showed you, the LOCATE command moved my text message 5 spaces down, and 4 spaces right. How about you try it on your own?

|
|
-------Can you guess where the text is? LOCATE (blank), (blank)

If you guessed LOCATE 2, 7, you are no doubt getting the hang of this! Remember, LOCATE [up/down], [right/left]!

Okay, you've conquered some simple things today. How about we try something else simple? It'll be a SOUND command, used for producing sound from your computer's internal speaker. Type "SOUND 45, 1" and press F5. Hear something? Now, change "45" to "3045" and press F5. It's higher, right? Change the "1" to "20" and strike F5. Your short beep has turned into a long wail. Keep practicing with the sounds, they're pretty fun!

Can you believe it? You now know CLS, PRINT, LOCATE, and SOUND! Those are four of the simplest commands. You'll have to practice these commands and understand them fully. Now take a break and rest your weary eyes, I'm sure they're tired. Before you move on witht he next tutorial, think about what you now know and what you can do with what you have learned. Take a much-needed break and go on to Chapter Three. See you there!


I'm ready for Chapter Three: Valuable Variables
Back to Tutorials