Part 4 - The "PRINT" Statement
We will start this tutorial with the print statement, this is the
easiest function to learn in qbasic. A good place to start your
qbasic careers!! It is used like this:
Type this in on the main blue screen and then press F5 to see the
first program you have done in qbasic!! This code should give
you a blank black screen with the words, which you put in the speech marks, so this
program, should just say :
On a blank black screen!! Now obviously to change what you want printed on the
screen you just change what was in the speech marks :
PRINT "WHATEVER YOU WANT PRINTED ON THE SCREEN"
However you should realise that after running the second program
the first program is still left on the screen. For example, after
you ran program 1 and then you made your own writing up then you
got something like this :
WHATEVER YOU WANT PRINTED ON THE SCREEN
In other words whatever you did previously is still on the screen. To
overcome this problem you will need to learn a simple function, which
takes us to our next chapter!!
Part 5 - The Clear Screen Function
After learning in Part 4 that you need to clear the screen you will
be wondering what the code you need is, well don't worry it is still
very easy!! Take a look:
This is the Clear Screen Function, it is simply "cls"
This will clear the screen back to blank everytime you run a program.
So you don't have your last program still on the screen. Easy isn't
it!! You will need to put it on the first line of your program, so that
it will clear the screen before doing the next operation!!!
QBasic has different screen modes depending on what you want to do!! Each screen mode
has a different resolution for your text, and pictures!!
Screen 0 is the default screen. So if you don't assign a screen then qbasic will use
this one!! Screen 1 gives you really big text
Screen 2 gives you a slightly bigger than screen 0 with an italic type of text
There are 13 screens for you to try out!!
How to use the screen statement:
By using this code you will see the difference which the screens make, to change the
screen mode just change the number after the screen function. Just remember that you can
So far what we have done has all been in plain black and white so why don't we spice it up a
bit!! By using the color statement!! The color statement is just as easy as the other functions,
and can be used for you to use different colors on your programs!!
- color 0 - gives you black writing ( * note the screen will be blank because the writing and
background colors are the same!!)
- color 1 - gives you blue writing
- color 2 - gives you a pretty green color
There are up to 17 normal colors (0 - 16)!! From color 17 - 30 you can get flashing colored
text!! However some screens do not support flashing text eg screen 9
To write in a red color the code is :
Screen 0 has been chosen as it is a normal screen which supports flashing text!!
This shows hi in a red font!!
To write in a flashing red font :
As you can see this shows "hi" in a red flashing text!!