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

Reinier's QBasic page: Lesson 1: PRINT

This command is the first command anyone should learn if they decide to learn QBasic. It is critical to any program.
PRINT "Text"
This will print the text that you type on the screen.

Example:
PRINT "Hello, this is Reinier's QBasic page"

Output:
Hello, this is Reinier's QBasic page


PRINT "Text"{;|,}
If you use ; the next thing you PRINT will be printed on the same line. If you use , the next thing you PRINT will be printed in the next column. The amount of colums depends on the screen you're using. This will be explained in a later lesson.

Example #1:
PRINT "Reinier"
PRINT "QBasic"

Output:
Reinier
QBasic

Example #2:
PRINT "Reinier";
PRINT "QBasic"

Output:
ReinierQBasic

Example #3:
PRINT "Reinier",
PRINT "QBasic"

Output:
Reinier [a certain amount of spaces, depending on the screen you're using] QBasic

You can also connect PRINT commands, like so:
PRINT "Text"{;|,}"Text2"{;|,}"Text3" and you can go on forever.


PRINT NumericalValue
This prints a numerical value onto the screen.

Example #1:
PRINT 7

Output:
7

Example #2:
PRINT 5+2

Output:
7

Note that you don't need " when printing numerical values. By the way, + is addition, - is subtraction, * is mulltiplication, and / is division.

You can of course link multiple numerical values and strings (strings are text entries).

Example:
PRINT "Reinier is";(6+20)/2;"years old.","QBasic"

Output:
Reinier is 13 years old. [certain amount of spaces] QBasic

Note that the spaces before and after the '13' are added automatically.


LPRINT
LPRINT does exactly the same thing as PRINT, and you can do anything with LPRINT that you can do with PRINT, but the only difference is that LPRINT prints whatever you want on the printer.

End of lesson 1.


Return to lessons
Return home