The first thing to learn in Basic, is how to get the computer to talk to you. This doesn't mean you are going to discuss the great philosophies of life (although nothing would stop you from writing a few algorithms to allow this), but lets start with something simple; saying hello.
The way of doing this is the PRINT command. It would look like this
10 PRINT "This is what would be printed on the screen"The PRINT command can be very useful. If used as shown in the example, you can print lines of text. However, the PRINT command can also be used to print numbers.
10 PRINT 987PRINT can also be used to do calculations. If PRINT is used with an equation such as 5+5, the result is printed.
10 PRINT 5 + 5When using the latest version of QBasic, PRINT can be easily typed by using a question mark ( ? ). The computer will automatically turn the ? into PRINT which makes typing easier.
10 ? "When you hit enter and go to the next line, the ? becomes PRINT"Another thing that can be used with PRINT is the comma. Commas placed in front of a PRINT statement will tab over the line once for each comma.
10 , , , PRINT "This is tabbed over three times"PRINT can also be used to print variables. This will be discussed in the chapter on INPUT statements. However, It should be known that PRINT can be used on the same line to print text, variables, and more text as follows.
10 PRINT "Text can go here " variable " with a variable in the middle, or vice versa, or in any combination"Try doing a short program of your own using PRINT. Play around and have some fun. Be sure to check back for more how to's.
QBasic Homeianmacallen.com | Annex | Archive
All content Copyright 2006 Ian MacAllen Unless otherwise Atrributed.
Contact:
ianmac47@hotmail.com