issue #4

Welcome to Qbasic

By Hal_8900

Well, you've got QBASIC or QuickBASIC on your system. Finally.

*BUT*

Now what??????

Obviously this article is geared towards the extreme beginner, so if you've ever made your own scrolling engine, move on. In this article I will explain some of the most basic QBASIC commands. Read along, and by the time you're finished, you'll be writing your own programs, easily!

First off, the following are the different commands you will learn from this article:

SCREEN, PRINT, LOCATE, CLS, COLOR, INPUT, SLEEP

SCREEN : The SCREEN command changes the resolution and colors available to the screen of your computer. Ever noticed how DOOM looks really blocky compared to Windows? Thats becuase DOOM was made in a resolution of 320 pixels by 200 pixels. Windows usually is set at a minimum of 640 pixels by 480 pixels. A pixel is one 'dot' on the computer screen. In this article, I will only demonstrate SCREEN 13. Check the QBASIC/QuickBASIC help file for more info on screen modes.

PRINT : The PRINT command 'prints' a string of alphanumeric characters to the screen. In plain english that means that it puts words and numbers on the screen. Proper syntax is PRINT "alphanumeric character(s)" (include the " ").

LOCATE : The LOCATE command is used to tell the computer just where on the screen you want to PRINT something. It's proper syntax is LOCATE row, column with row and column both being numbers. The amount of rows and columns depends on the SCREEN mode, but it is generally 24 rows, and 80 columns. 1 letter or number will occupy 1 row,column space.

CLS : The CLS command does nothing more than clear the screen.

COLOR : The COLOR command changes the color of everything you PRINT to the screen. Proper syntax is COLOR n where n is the number of the color. Check the QBASIC help file for the different color codes.

INPUT: The INPUT command lets the user type in whatever they want, and it will save what they type to what is called a variable. Proper syntax is INPUT "Please type something in " , variable$ You can either leave out the "Please type something in" or leave it in, and you can define whatever phrase to use. variable$ is the variable which saves what the user types in. The $ at the end is to define just what type of variable it is, but I'll explain those later.

SLEEP: The SLEEP command makes the computer wait until the user presses a key. In effect, the computer "sleeps"

OK! Now I've showed you each command and what they do, time to show your skills! Here's an example program which uses all of the commands above.

SCREEN 13
COLOR 1
PRINT "Hello,
World!"
SLEEP
CLS
LOCATE 1, 14
PRINT "Hello,
World!"
SLEEP
CLS
INPUT "Whats your
name?", name$
CLS
PRINT "Hello, "
, name$
SLEEP
END

There! Isn't that program just wonderful? Notice how with PRINT "Hello, " , name$ you could print what the user typed? You can use this to make lots of cool programs!!!!

Oh yeah, I said I'd explain the different types of variables. Basically there are 2 important types for a beginner to remember:

% and $. % is for variables which are only used for numbers, while $ is for strings of letters and numbers. Thats all there is to know. Be sure to read through your QB help file, it contains even more info on all these commands! SO GET OUT THERE AND START PROGRAMMING! :p

Back to Top





This tutorial originally appeared in QBasic: The Magazine Issue 4.