(If any site owner wishes to use my easy to learn tutorials on their own site please 
contact me from the web site first)



Starting out

We know from the last tutorial if read, what Qbasic, is, who made it and where it comes from 
sort of.  Well now lets start the programming.

PRINT COMMAND

It would be a very dark day if we didn't have a print command.  
This command in basic is used to input writing on the screen.  
To use it, we start the first line off like so:


PRINT "Hello world" 


(Run the program)

This would 'print' 'Hello world' on the top left hand corner of the screen.
Congratulations, you have written your first program.
It will be in the top left hand corner because that is the default starting location 
of any output on the screen unless specified other wise (We'll come to that in a mo)
Notice the "" the speech marks tell the computer that what ever is inside them will 
get printed on the screen, so try


PRINT "Hello to you"
PRINT "Who"
PRINT "To you"


Note how the computer is clever enough to push the text down when the next line comes into play.

Good, now you can Type text onto the screen, next is to position that text to look good.
The next command is used to make the start of the text appear at the specified co-ordinates.  
The command is

LOCATE 5, 5

The Locate tells the computer that what ever follows this, will get outputted starting at that 
co-ordinate.  As you could possibly guess, 5, 5 are the co-ordinates (x,y) .  So try this:


LOCATE 25,24
PRINT "I'm over here"
LOCATE 10,15
PRINT "And here"


So, as you can see, this allows you to move text around the screen.  
The co-ordinates are based on line numbers going down and character blocks going across.
So in "I'm over here" it started at 25 across, so I is 25, o is 29 etc.

You may have noticed that you are building up quite an array of words on the 
output screen (Screen seen when running the program), 
this is because each time you are creating a new program, the output screen is remaining the same.  
So in that case, if we have something that can output onto the screen, we need something that 
can remove it when wanted.  That is known as the CLS command, standing for Clear Screen, 
it's used thus


CLS
PRINT "Hello"
CLS
PRINT "Goodbye"


In this, notice how you can only see goodbye, that is because Qbasic runs the commands 
so quickly, you don't see the hello before it is wiped off the screen.  So in slow mo, 
the screen is being cleared of previous outputs, printing hello, but then clearing the 
screen again, and printing Goodbye which stays on the screen as nothing comes after it to 
clear it.

Okay, you should by now have it firmly lodged in your brain that PRINT inputs text to the screen, 
LOCATE allows that text to be position using the (x,y) co-ordinates, and that CLS, 
Clears the screen of all outputs made.
One last program combining them then:


CLS                                     'Clears the screen first
Locate 20,20                            'Unusual position on the screen
Print "Hello down there"                'Prints on the screen
Locate 20,80                            'Further down on the screen   
Print "Hello Up there"                  'prints on the screen again


You should be able to run that program over and over again and change the text and 
co-ordinates because the CLS Will wipe anything before starting again.

Whew, well, I hope you get all of that, that concludes the second of the beginners tutorials, 
please continue to the next if you wish.
Oh, and I find the best way to remember all of this is to play with it, write programs for fun, 
experiment, that's half the fun of programming!.

Written by Jamie for anyone.


                                                                                                                                                                                                                                                                                                                                                                                                                               

    Source: geocities.com/jamo20010